Skip to content

Build release artifacts #88

Build release artifacts

Build release artifacts #88

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 and Docker image"
strategy:
matrix:
os:
- runs-on: ubuntu-24.04
architecture: x86_64
- runs-on: ubuntu-24.04-arm
architecture: arm64
runs-on: ${{ matrix.os.runs-on }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event_name == 'release' && '' || github.event.inputs.release_tag }}
- uses: cachix/install-nix-action@v31
name: "Installing Nix"
with:
extra_nix_config: |
experimental-features = nix-command flakes
accept-flake-config = true
nix_path: "nixpkgs=channel:nixos-unstable"
- name: "Build static binary"
run: |
nix build --log-format raw-with-logs .#nickel-static
cp ./result/bin/nickel nickel-${{ matrix.os.architecture }}-linux
cp ./result/bin/nls nls-${{ matrix.os.architecture }}-linux
nix build --log-format raw-with-logs .#nickel-pkg-static
cp ./result/bin/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: |
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
- id: build-image
name: "Build docker image"
run: |
nix build --log-format raw-with-logs .#dockerImage
cp ./result nickel-${{ matrix.os.architecture }}-docker-image.tar.gz
echo "imageName=$(nix eval --raw .#dockerImage.imageName)" >> "$GITHUB_OUTPUT"
echo "imageTag=$(nix eval --raw .#dockerImage.imageTag)" >> "$GITHUB_OUTPUT"
- name: "Upload docker image 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: |
gh release upload --clobber $RELEASE_TAG nickel-${{ matrix.os.architecture }}-docker-image.tar.gz
- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
env:
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }}
TARBALL_TAG: ${{ steps.build-image.outputs.imageName }}:${{ steps.build-image.outputs.imageTag }}
run: |
docker load -i nickel-${{ matrix.os.architecture }}-docker-image.tar.gz
docker tag "$TARBALL_TAG" ghcr.io/tweag/nickel:$RELEASE_TAG-${{ matrix.os.architecture}}
docker push ghcr.io/tweag/nickel:$RELEASE_TAG-${{ matrix.os.architecture}}
docker-multiplatform-image:
name: "Assemble multi-platform Docker image"
runs-on: ubuntu-latest
needs: release-artifacts
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@v5
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