ci: improve tip release with source archive, tag pinning, and concurr… #15
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
| name: Tip (Nightly) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| # Only run one tip release at a time to prevent corrupting release artifacts. | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: false | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| commit: ${{ steps.info.outputs.commit }} | |
| commit_long: ${{ steps.info.outputs.commit_long }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Extract build info | |
| id: info | |
| run: | | |
| echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| echo "commit_long=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
| source: | |
| needs: [setup] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create source archive | |
| run: | | |
| git archive --format=zip --prefix=snipp-${{ needs.setup.outputs.commit }}/ HEAD \ | |
| -o snipp-source.zip | |
| - name: Upload source archive | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: source | |
| path: snipp-source.zip | |
| build-macos: | |
| needs: [setup] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - args: '--target aarch64-apple-darwin' | |
| arch: 'silicon' | |
| - args: '--target x86_64-apple-darwin' | |
| arch: 'intel' | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-apple-darwin,x86_64-apple-darwin | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './src-tauri -> target' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build frontend | |
| run: npm run build | |
| - name: Build Tauri app (${{ matrix.arch }}) | |
| run: npm run tauri:build -- ${{ matrix.args }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dmg-${{ matrix.arch }} | |
| path: src-tauri/target/*/release/bundle/dmg/*.dmg | |
| tag: | |
| needs: [setup, build-macos, source] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Force-update tip tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag -fa tip -m "Latest Continuous Release" ${GITHUB_SHA} | |
| git push --force origin tip | |
| release: | |
| needs: [setup, build-macos, source, tag] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Update tip release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: tip | |
| target_commitish: ${{ github.sha }} | |
| name: 'Snipp Tip ("Nightly")' | |
| prerelease: true | |
| body: | | |
| This tip release is automatically built on every commit to main. | |
| **Warning: This is a nightly build, not a tagged release.** | |
| Built from commit: ${{ needs.setup.outputs.commit_long }} | |
| **Apple Silicon** (M1+): `Snipp_*_aarch64.dmg` | **Intel**: `Snipp_*_x64.dmg` | |
| After installing, remove the quarantine flag: | |
| ``` | |
| xattr -d com.apple.quarantine /Applications/Snipp.app | |
| ``` | |
| files: | | |
| artifacts/**/*.dmg | |
| artifacts/snipp-source.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |