Merge pull request #7 from intelliDean/fix-publish-silent-failure #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Atupa Release β Automated Binary Compilation & Publishing | |
| # | |
| # Triggered when a new version tag (v*) is pushed. | |
| # Performs a cross-platform matrix build (Linux, macOS, Windows), | |
| # bundles the Studio frontend into the binary, and creates a GitHub Release. | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| name: π Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # ββ Phase 1: Create the Release Draft ββββββββββββββββββββββββββββββββββββββ | |
| create-release: | |
| name: π Create GitHub Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| draft: true | |
| prerelease: false | |
| generate_release_notes: true | |
| # ββ Phase 2: Build Binaries (Matrix) βββββββββββββββββββββββββββββββββββββββ | |
| build-binaries: | |
| name: π οΈ Build for ${{ matrix.target }} | |
| needs: create-release | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| artifact_name: atupa-linux-x86_64 | |
| asset_name: atupa-linux-x86_64.tar.gz | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| artifact_name: atupa-macos-arm64 | |
| asset_name: atupa-macos-arm64.tar.gz | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| artifact_name: atupa-macos-x86_64 | |
| asset_name: atupa-macos-x86_64.tar.gz | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| artifact_name: atupa-windows-x64 | |
| asset_name: atupa-windows-x64.zip | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Rust build | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: atupa-release-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }} | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| cache-dependency-path: 'studio/package-lock.json' | |
| # π¨ Studio Frontend must be built for the binary to embed it | |
| - name: Build Atupa Studio | |
| shell: bash | |
| run: | | |
| cd studio | |
| npm install | |
| npm run build | |
| - name: Build Atupa CLI | |
| shell: bash | |
| run: cargo build --release --target ${{ matrix.target }} -p atupa | |
| # π¦ Packaging | |
| - name: Package Binary (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar czf ../../../${{ matrix.asset_name }} atupa | |
| cd ../../../ | |
| - name: Package Binary (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| Compress-Archive -Path atupa.exe -DestinationPath ../../../${{ matrix.asset_name }} | |
| cd ../../../ | |
| # π Upload to the release created in Phase 1 | |
| - name: Upload Asset to Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ matrix.asset_name }} | |
| tag_name: ${{ github.ref_name }} | |
| # ββ Phase 3: Publish to Crates.io ββββββββββββββββββββββββββββββββββββββββββ | |
| publish-crates: | |
| name: π¦ Publish to Crates.io | |
| needs: build-binaries | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Publish Workspace | |
| shell: bash | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
| run: | | |
| if [ -z "$CARGO_REGISTRY_TOKEN" ]; then | |
| echo "β οΈ CRATES_IO_TOKEN not found. Skipping publish step." | |
| exit 0 | |
| fi | |
| ./publish.sh |