fix(release): use portable sed -i.bak (v0.1.2's macOS build broke) #5
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: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| cross: true | |
| - target: aarch64-unknown-linux-musl | |
| os: ubuntu-latest | |
| cross: true | |
| - target: aarch64-apple-darwin | |
| os: macos-14 | |
| cross: false | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| lfs: true | |
| - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| # Workspace version defaults to whatever was last committed to | |
| # Cargo.toml, which drifts from the release tag if nobody remembers to | |
| # bump it by hand — stamp it from the tag so `ci --version` always | |
| # matches the artifact it shipped in. | |
| - name: Set crate version from tag | |
| # `-i.bak` (suffix glued to the flag, no space) is the one `sed -i` | |
| # spelling both GNU sed (Linux runners) and BSD sed (macOS runner) | |
| # accept the same way — a bare `-i` is GNU-only and errors on BSD. | |
| run: | | |
| sed -i.bak "s/^version = \".*\"/version = \"${GITHUB_REF_NAME#v}\"/" Cargo.toml | |
| rm -f Cargo.toml.bak | |
| # `cross` runs the build in a container that already has the C | |
| # cross-toolchain tree-sitter / stack-graphs / rusqlite need. | |
| - name: Install cross | |
| if: matrix.cross | |
| run: cargo install cross --locked | |
| - name: Build (cross) | |
| if: matrix.cross | |
| run: cross build --release --bin ci --target ${{ matrix.target }} | |
| - name: Build (native) | |
| if: ${{ !matrix.cross }} | |
| run: cargo build --release --bin ci --target ${{ matrix.target }} | |
| - name: Package | |
| run: | | |
| bin="target/${{ matrix.target }}/release/ci" | |
| tar -czf "ci-${{ matrix.target }}.tar.gz" -C "$(dirname "$bin")" ci | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: ci-${{ matrix.target }} | |
| path: ci-${{ matrix.target }}.tar.gz | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate checksums | |
| working-directory: dist | |
| run: sha256sum ci-*.tar.gz > SHA256SUMS | |
| - name: Publish release | |
| uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 | |
| with: | |
| files: | | |
| dist/*.tar.gz | |
| dist/SHA256SUMS | |
| generate_release_notes: true | |
| docker: | |
| name: Publish container image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| lfs: true | |
| - name: Log in to GHCR | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Resolve image tag | |
| id: version | |
| run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 | |
| with: | |
| context: . | |
| file: Containerfile | |
| push: true | |
| tags: | | |
| ghcr.io/eilodon/code-intelligence:${{ steps.version.outputs.version }} | |
| ghcr.io/eilodon/code-intelligence:latest |