Build release artifacts #82
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 release artifacts | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: "The release tag to target" | |
| permissions: | |
| id-token: write | |
| contents: write | |
| packages: write | |
| jobs: | |
| release-artifacts: | |
| name: "Build Nickel binary" | |
| strategy: | |
| matrix: | |
| os: | |
| - runs-on: ubuntu-24.04 | |
| architecture: x86_64 | |
| rust_architecture: x86_64 | |
| - runs-on: ubuntu-24.04-arm | |
| architecture: arm64 | |
| rust_architecture: aarch64 | |
| runs-on: ${{ matrix.os.runs-on }} | |
| container: | |
| image: alpine:3.22 | |
| steps: | |
| - name: "Install dev tools" | |
| run: | | |
| apk add rustup gcc musl-dev python3 github-cli git | |
| rustup-init -y | |
| - name: "git checkout" | |
| run: | | |
| git clone https://github.com/tweag/nickel | |
| cd nickel | |
| git checkout ${{ github.event_name == 'release' && '' || github.event.inputs.release_tag }} | |
| - name: "Build static binaries" | |
| run: | | |
| source $HOME/.cargo/env | |
| cd nickel | |
| cargo build --target ${{ matrix.os.rust_architecture }}-unknown-linux-musl -p nickel-lang-cli -p nickel-lang-lsp --release | |
| cp ./target/${{ matrix.os.rust_architecture }}-unknown-linux-musl/release/nickel nickel-${{ matrix.os.architecture }}-linux | |
| cp ./target/${{ matrix.os.rust_architecture }}-unknown-linux-musl/release/nls nls-${{ matrix.os.architecture }}-linux | |
| cargo build --target ${{ matrix.os.rust_architecture }}-unknown-linux-musl -p nickel-lang-cli --features=package-experimental --release | |
| cp ./target/${{ matrix.os.rust_architecture }}-unknown-linux-musl/release/nickel nickel-pkg-${{ matrix.os.architecture }}-linux | |
| - name: "Upload static binary as release asset" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }} | |
| run: | | |
| cd nickel | |
| gh release upload --clobber $RELEASE_TAG nickel-${{ matrix.os.architecture }}-linux | |
| gh release upload --clobber $RELEASE_TAG nickel-pkg-${{ matrix.os.architecture }}-linux | |
| gh release upload --clobber $RELEASE_TAG nls-${{ matrix.os.architecture }}-linux | |
| docker-image: | |
| name: "Assemble single-platform Docker image" | |
| strategy: | |
| matrix: | |
| os: | |
| - runs-on: ubuntu-24.04 | |
| architecture: x86_64 | |
| rust_architecture: x86_64 | |
| - runs-on: ubuntu-24.04-arm | |
| architecture: arm64 | |
| rust_architecture: aarch64 | |
| runs-on: ${{ matrix.os.runs-on }} | |
| needs: release-artifacts | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to registry | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
| - id: build-image | |
| name: "Build docker image" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }} | |
| run: | | |
| gh release download --clobber $RELEASE_TAG --pattern nickel-${{ matrix.os.architecture }}-linux -O nickel | |
| gh release download --clobber $RELEASE_TAG --pattern nls-${{ matrix.os.architecture }}-linux -O nls | |
| docker build -t ghcr.io/tweag/nickel:$RELEASE_TAG-${{ matrix.os.architecture }} . | |
| docker push ghcr.io/tweag/nickel:$RELEASE_TAG-${{ matrix.os.architecture }} | |
| docker save ghcr.io/tweag/nickel:$RELEASE_TAG-${{ matrix.os.architecture }} -o nickel-${{ matrix.os.architecture }}-docker-image.tar.gz | |
| gh release upload --clobber $RELEASE_TAG nickel-${{ matrix.os.architecture }}-docker-image.tar.gz | |
| docker-multiplatform-image: | |
| name: "Assemble multi-platform Docker image" | |
| runs-on: ubuntu-latest | |
| needs: docker-image | |
| steps: | |
| - name: Log in to registry | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
| - name: Assemble and push image | |
| env: | |
| RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }} | |
| run: | | |
| docker buildx imagetools create -t ghcr.io/tweag/nickel:$RELEASE_TAG ghcr.io/tweag/nickel:$RELEASE_TAG-x86_64 ghcr.io/tweag/nickel:$RELEASE_TAG-arm64 | |
| docker buildx imagetools inspect ghcr.io/tweag/nickel:$RELEASE_TAG | |
| # release-artifacts-macos: | |
| # name: "Build MacOS Nickel binaries" | |
| # runs-on: [self-hosted, macOS, ARM64] | |
| # steps: | |
| # - uses: actions/checkout@v4 | |
| # with: | |
| # ref: ${{ github.event_name == 'release' && '' || github.event.inputs.release_tag }} | |
| # - name: Build binaries | |
| # run: | | |
| # set +e | |
| # nix build --log-format raw-with-logs .#nickel-lang | |
| # cp ./result/bin/nickel nickel-arm64-macos | |
| # cp ./result/bin/nls nls-arm64-macos | |
| # nix build --log-format raw-with-logs .#nickel-lang-pkg | |
| # cp ./result/bin/nickel nickel-pkg-arm64-macos | |
| # - name: "Upload binaries as release assets" | |
| # env: | |
| # GH_TOKEN: ${{ github.token }} | |
| # RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }} | |
| # run: | | |
| # gh release upload --clobber $RELEASE_TAG nickel-arm64-macos | |
| # gh release upload --clobber $RELEASE_TAG nls-arm64-macos | |
| # release-artifacts-windows: | |
| # name: "Build Windows Nickel binaries" | |
| # runs-on: windows-latest | |
| # steps: | |
| # - uses: actions/checkout@v4 | |
| # with: | |
| # ref: ${{ github.event_name == 'release' && '' || github.event.inputs.release_tag }} | |
| # - name: Build binaries | |
| # run: | | |
| # cargo build --release --package nickel-lang-cli | |
| # cp ./target/release/nickel.exe nickel-x86_64-windows.exe | |
| # cargo build --release --package nickel-lang-cli --features "package-experimental" | |
| # cp ./target/release/nickel.exe nickel-pkg-x86_64-windows.exe | |
| # cargo build --release --package nickel-lang-lsp | |
| # cp ./target/release/nls.exe nls-x86_64-windows.exe | |
| # - name: "Upload binaries as release assets" | |
| # env: | |
| # GH_TOKEN: ${{ github.token }} | |
| # RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }} | |
| # run: | | |
| # echo $Env:RELEASE_TAG | |
| # ls | |
| # gh release upload --clobber $Env:RELEASE_TAG nickel-x86_64-windows.exe | |
| # gh release upload --clobber $Env:RELEASE_TAG nickel-pkg-x86_64-windows.exe | |
| # gh release upload --clobber $Env:RELEASE_TAG nls-x86_64-windows.exe |