name: Build and Release on: workflow_dispatch: push: tags: - "v*" branches: - master jobs: build: name: Build ${{ matrix.platform }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - platform: windows-x64 os: windows-latest target: x86_64-pc-windows-msvc - platform: windows-arm64 os: windows-latest target: aarch64-pc-windows-msvc - platform: macos-x64 os: macos-latest target: x86_64-apple-darwin - platform: macos-arm64 os: macos-latest target: aarch64-apple-darwin - platform: linux-x64 os: ubuntu-latest target: x86_64-unknown-linux-gnu steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} # Windows and macOS builds using cargo-packager - name: Install cargo-packager if: runner.os != 'Linux' run: cargo install cargo-packager --locked - name: Build with cargo-packager (Windows/macOS) if: runner.os != 'Linux' working-directory: crates/coop run: cargo packager --release --target ${{ matrix.target }} --config before-packaging-command="cargo build --release --target ${{ matrix.target }}" - name: Upload Windows/macOS artifacts if: runner.os != 'Linux' uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform }}-artifacts path: crates/coop/dist/**/* if-no-files-found: error # Linux builds using custom scripts - name: Install Linux build dependencies if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y flatpak flatpak-builder snapd squashfs-tools jq gettext-base sudo snap install snapcraft --classic - name: Make scripts executable if: runner.os == 'Linux' run: | chmod +x script/get-crate-version chmod +x script/snap-build chmod +x script/bundle-linux chmod +x script/flatpak/deps chmod +x script/flatpak/bundle-flatpak - name: Build Flatpak if: runner.os == 'Linux' working-directory: script/flatpak run: | ./deps ./bundle-flatpak - name: Build Snap if: runner.os == 'Linux' run: | VERSION=$(script/get-crate-version coop) script/snap-build $VERSION - name: Collect Linux artifacts if: runner.os == 'Linux' run: | mkdir -p linux-artifacts # Find and copy flatpak files find . -name "*.flatpak" -exec cp {} linux-artifacts/ \; # Find and copy snap files find . -name "*.snap" -exec cp {} linux-artifacts/ \; ls -la linux-artifacts/ - name: Upload Linux artifacts if: runner.os == 'Linux' uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform }}-artifacts path: linux-artifacts/**/* if-no-files-found: error release: name: Create Release needs: build runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' steps: - name: Checkout repository uses: actions/checkout@v4 - name: Make get-crate-version executable run: chmod +x script/get-crate-version - name: Get version id: version run: | VERSION=$(script/get-crate-version coop) echo "version=$VERSION" >> $GITHUB_OUTPUT echo "tag=v$VERSION" >> $GITHUB_OUTPUT - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: Display artifacts structure run: | echo "Artifacts structure:" find artifacts -type f -exec ls -la {} \; - name: Create draft release id: create_release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.version.outputs.tag }} name: Release ${{ steps.version.outputs.tag }} draft: true prerelease: false generate_release_notes: true files: | artifacts/**/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Output release info run: | echo "Created draft release: ${{ steps.create_release.outputs.url }}" echo "Release ID: ${{ steps.create_release.outputs.id }}"