Build and Release Binaries #14
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: Build and Release Binaries | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build Binaries | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Install Crystal | |
| uses: crystal-lang/install-crystal@v1 | |
| - name: Checkout source code | |
| uses: actions/checkout@v6 | |
| - name: Install dependencies | |
| run: shards install | |
| - name: Inject slug/short variables | |
| uses: rlespinasse/github-slug-action@v5 | |
| - name: Set architecture environment variable | |
| run: | | |
| if [ "$RUNNER_ARCH" == "X64" ]; then | |
| echo "ARCH=x86_64" >> $GITHUB_ENV | |
| elif [ "$RUNNER_ARCH" == "ARM64" ]; then | |
| echo "ARCH=arm64" >> $GITHUB_ENV | |
| else | |
| echo "ARCH=unknown" >> $GITHUB_ENV | |
| fi | |
| - if: matrix.os == 'ubuntu-latest' | |
| name: Build binary (Linux) | |
| run: | | |
| mkdir -p build | |
| # Use Crystal container to build static binary | |
| docker run --rm -v $(pwd):/noir -w /noir --entrypoint="" crystallang/crystal:1.20.0-alpine sh -c " | |
| apk add --no-cache yaml-dev zstd-dev git curl && | |
| shards install --production && | |
| mkdir -p build && | |
| crystal build src/noir.cr -o build/noir-${GITHUB_REF_SLUG}-linux-${ARCH} --release --no-debug --static | |
| " | |
| - if: startsWith(matrix.os, 'macos') | |
| name: Build binary (macOS) | |
| run: | | |
| mkdir -p build | |
| crystal build src/noir.cr \ | |
| -o build/noir-${GITHUB_REF_SLUG}-osx-${ARCH} \ | |
| --no-debug --release | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: build-${{ matrix.os }}-${{ env.ARCH }} | |
| path: build | |
| - if: startsWith(github.ref, 'refs/tags/') | |
| name: Upload to GitHub Releases | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| file_glob: true | |
| file: build/* |