WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Build release artifacts #95

Build release artifacts

Build release artifacts #95

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: "Build static library"
run: |
nix build --log-format raw-with-logs .#nickel-lang-c
cp ./result/lib/libnickel_lang.a libnickel_lang-${{ matrix.os.architecture }}-linux.a
cp ./result/lib/libnickel_lang.so libnickel_lang-${{ matrix.os.architecture }}-linux.so
# The header file shouldn't depend on the architecture.
cp ./result/include/nickel_lang.h nickel_lang.h
- name: "Upload binaries/libraries 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-${{ 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
gh release upload --clobber $RELEASE_TAG libnickel_lang-${{ matrix.os.architecture }}-linux.a
gh release upload --clobber $RELEASE_TAG libnickel_lang-${{ matrix.os.architecture }}-linux.so
gh release upload --clobber $RELEASE_TAG nickel_lang-linux.h
- 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: "Build static library"
run: |
nix build --log-format raw-with-logs .#nickel-lang-c
cp ./result/lib/libnickel_lang.a libnickel_lang-arm64-macos.a
cp ./result/lib/libnickel_lang.dylib libnickel_lang-arm64-macos.dylib
- name: "Upload binaries/libraries 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
gh release upload --clobber $RELEASE_TAG libnickel_lang-arm64-macos.a
gh release upload --clobber $RELEASE_TAG libnickel_lang-arm64-macos.dylib
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: Install LLVM tools
run: |
curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.8/clang+llvm-20.1.8-x86_64-pc-windows-msvc.tar.xz -o llvm.tar.xz
mkdir llvm
tar xJvf llvm.tar.xz --strip-components=1 -C llvm
- name: Install MinGW target
run: rustup target add x86_64-pc-windows-gnu
- 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: Build libraries
shell: bash
run: |
cargo build --package nickel-lang --features=capi --release --target x86_64-pc-windows-gnu
export PATH="$PWD/llvm/bin:$PATH"
bash ./scripts/shrink_archive.sh -o libnickel_lang-x86_64-windows-mingw.a \
./target/x86_64-windows-mingw/release/nickel_lang.a
cp ./target/x86_64-windows-mingw/release/nickel_lang.dll libnickel_lang-x86_64-windows-mingw.dll
- 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
gh release upload --clobber $Env:RELEASE_TAG nls-x86_64-windows.exe
gh release upload --clobber $Env:RELEASE_TAG libnickel_lang-x86_64-windows-mingw.a
gh release upload --clobber $Env:RELEASE_TAG libnickel_lang-x86_64-windows-mingw.dll