feat: cross-PR conflict intelligence #10
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 | |
| id-token: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| BINARY_NAME: grove | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| use_cross: true | |
| archive_ext: tar.gz | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| use_cross: true | |
| archive_ext: tar.gz | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| use_cross: false | |
| archive_ext: tar.gz | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| use_cross: false | |
| archive_ext: tar.gz | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Cargo registry and build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ matrix.target }}-cargo- | |
| - name: Install cross | |
| if: matrix.use_cross == true | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cross | |
| - name: Build release binary (cross) | |
| if: matrix.use_cross == true | |
| run: cross build --release --target ${{ matrix.target }} -p grove | |
| - name: Build release binary (cargo) | |
| if: matrix.use_cross == false | |
| run: cargo build --release --target ${{ matrix.target }} -p grove | |
| - name: Determine archive name | |
| id: archive | |
| shell: bash | |
| run: | | |
| VERSION="${GITHUB_REF_NAME}" | |
| ARCHIVE_STEM="${{ env.BINARY_NAME }}-${VERSION}-${{ matrix.target }}" | |
| echo "stem=${ARCHIVE_STEM}" >> "$GITHUB_OUTPUT" | |
| echo "filename=${ARCHIVE_STEM}.${{ matrix.archive_ext }}" >> "$GITHUB_OUTPUT" | |
| - name: Package binary (Unix tar.gz) | |
| if: matrix.archive_ext == 'tar.gz' | |
| shell: bash | |
| run: | | |
| STEM="${{ steps.archive.outputs.stem }}" | |
| mkdir -p "dist/${STEM}" | |
| cp "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}" "dist/${STEM}/" | |
| cp README.md LICENSE-MIT LICENSE-APACHE dist/${STEM}/ 2>/dev/null || true | |
| tar -czf "dist/${{ steps.archive.outputs.filename }}" -C dist "${STEM}" | |
| - name: Generate checksum | |
| shell: bash | |
| run: | | |
| cd dist | |
| if command -v sha256sum &>/dev/null; then | |
| sha256sum "${{ steps.archive.outputs.filename }}" > "${{ steps.archive.outputs.filename }}.sha256" | |
| else | |
| shasum -a 256 "${{ steps.archive.outputs.filename }}" > "${{ steps.archive.outputs.filename }}.sha256" | |
| fi | |
| - name: Upload archive artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.archive.outputs.stem }} | |
| path: | | |
| dist/${{ steps.archive.outputs.filename }} | |
| dist/${{ steps.archive.outputs.filename }}.sha256 | |
| if-no-files-found: error | |
| retention-days: 3 | |
| release: | |
| name: Publish GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts/ | |
| - name: Collect release assets | |
| shell: bash | |
| run: | | |
| mkdir -p release-assets | |
| find artifacts/ -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.sha256" \) \ | |
| -exec cp {} release-assets/ \; | |
| echo "Assets to upload:" | |
| ls -lh release-assets/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: Grove ${{ github.ref_name }} | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| generate_release_notes: true | |
| files: release-assets/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-npm-binaries: | |
| name: Publish npm ${{ matrix.pkg_name }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| pkg_name: grove-linux-x64 | |
| node_os: linux | |
| node_arch: x64 | |
| - target: aarch64-unknown-linux-gnu | |
| pkg_name: grove-linux-arm64 | |
| node_os: linux | |
| node_arch: arm64 | |
| - target: x86_64-apple-darwin | |
| pkg_name: grove-darwin-x64 | |
| node_os: darwin | |
| node_arch: x64 | |
| - target: aarch64-apple-darwin | |
| pkg_name: grove-darwin-arm64 | |
| node_os: darwin | |
| node_arch: arm64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - name: Derive version from tag | |
| id: version | |
| shell: bash | |
| run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ env.BINARY_NAME }}-${{ github.ref_name }}-${{ matrix.target }} | |
| path: artifact/ | |
| - name: Build platform package | |
| shell: bash | |
| env: | |
| pkg_name: ${{ matrix.pkg_name }} | |
| version: ${{ steps.version.outputs.version }} | |
| target: ${{ matrix.target }} | |
| node_os: ${{ matrix.node_os }} | |
| node_arch: ${{ matrix.node_arch }} | |
| run: | | |
| mkdir -p pkg/bin | |
| envsubst < npm/package.json.tmpl > pkg/package.json | |
| STEM="${BINARY_NAME}-${GITHUB_REF_NAME}-${{ matrix.target }}" | |
| tar -xzf "artifact/${STEM}.tar.gz" -C pkg/bin --strip-components=1 "${STEM}/grove" | |
| chmod +x pkg/bin/grove | |
| test -f pkg/bin/grove || { echo "::error::Binary not found after extraction"; exit 1; } | |
| cat pkg/package.json | |
| - name: Publish to npm | |
| run: npm publish --access public --provenance | |
| working-directory: pkg | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| publish-npm-base: | |
| name: Publish npm @nathan2406/grove | |
| needs: publish-npm-binaries | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - name: Patch version from tag | |
| shell: bash | |
| env: | |
| TAG: ${{ github.ref_name }} | |
| run: | | |
| cd npm/grove | |
| node -e " | |
| const ver = process.env.TAG.replace(/^v/, ''); | |
| const pkg = require('./package.json'); | |
| pkg.version = ver; | |
| for (const dep of Object.keys(pkg.optionalDependencies || {})) { | |
| pkg.optionalDependencies[dep] = ver; | |
| } | |
| require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| echo "Publishing version:" | |
| cat package.json | |
| - name: Publish to npm | |
| run: npm publish --access public --provenance | |
| working-directory: npm/grove | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |