chore: move demo assets to .github/assets/ #8
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
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.target }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| # macOS | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact: mino-x86_64-apple-darwin | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact: mino-aarch64-apple-darwin | |
| # Linux | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact: mino-x86_64-unknown-linux-gnu | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| artifact: mino-aarch64-unknown-linux-gnu | |
| cross: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| if: ${{ !matrix.cross }} | |
| - name: Install cross | |
| if: matrix.cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build (native) | |
| if: ${{ !matrix.cross }} | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Build (cross) | |
| if: matrix.cross | |
| run: cross build --release --target ${{ matrix.target }} | |
| - name: Package | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar czvf ../../../${{ matrix.artifact }}.tar.gz mino | |
| cd ../../.. | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: ${{ matrix.artifact }}.tar.gz | |
| release: | |
| name: Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| sha256sum *.tar.gz > checksums.txt | |
| cat checksums.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| artifacts/*.tar.gz | |
| artifacts/checksums.txt | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-crates: | |
| name: Publish to crates.io | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Publish to crates.io | |
| run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} | |
| publish-npm: | |
| name: Publish to npm | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Prepare platform packages | |
| run: | | |
| # Extract binaries and copy to npm package directories | |
| # darwin-x64 | |
| tar xzf artifacts/mino-x86_64-apple-darwin.tar.gz | |
| cp mino npm/mino-darwin-x64/bin/ | |
| rm mino | |
| # darwin-arm64 | |
| tar xzf artifacts/mino-aarch64-apple-darwin.tar.gz | |
| cp mino npm/mino-darwin-arm64/bin/ | |
| rm mino | |
| # linux-x64 | |
| tar xzf artifacts/mino-x86_64-unknown-linux-gnu.tar.gz | |
| cp mino npm/mino-linux-x64/bin/ | |
| rm mino | |
| # linux-arm64 | |
| tar xzf artifacts/mino-aarch64-unknown-linux-gnu.tar.gz | |
| cp mino npm/mino-linux-arm64/bin/ | |
| rm mino | |
| - name: Update package versions | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| # Update all package.json files with the release version | |
| for pkg in mino mino-darwin-x64 mino-darwin-arm64 mino-linux-x64 mino-linux-arm64; do | |
| jq --arg v "$VERSION" '.version = $v' npm/$pkg/package.json > tmp.json && mv tmp.json npm/$pkg/package.json | |
| done | |
| # Update optionalDependencies versions in main package | |
| jq --arg v "$VERSION" '.optionalDependencies = (.optionalDependencies | to_entries | map(.value = $v) | from_entries)' npm/mino/package.json > tmp.json && mv tmp.json npm/mino/package.json | |
| - name: Publish platform packages | |
| run: | | |
| for pkg in mino-darwin-x64 mino-darwin-arm64 mino-linux-x64 mino-linux-arm64; do | |
| echo "Publishing @dean0x/$pkg..." | |
| cd npm/$pkg | |
| npm publish --access public | |
| cd ../.. | |
| done | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish main package | |
| run: | | |
| echo "Publishing @dean0x/mino..." | |
| cd npm/mino | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| trigger-homebrew: | |
| name: Trigger Homebrew update | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Trigger formula update | |
| run: | | |
| curl -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.HOMEBREW_TAP_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/repos/dean0x/homebrew-tap/dispatches \ | |
| -d '{"event_type":"update-formula","client_payload":{"formula":"mino","version":"${{ steps.version.outputs.version }}"}}' |