Skip to content

fix: exclude self-referencing archive from tar and reorder npm version #3

fix: exclude self-referencing archive from tar and reorder npm version

fix: exclude self-referencing archive from tar and reorder npm version #3

Workflow file for this run

name: Release
on:
push:
tags: ['v*']
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux-x86_64
zig_target: x86_64-linux-musl
ext: ""
- os: ubuntu-latest
target: linux-aarch64
zig_target: aarch64-linux-musl
ext: ""
- os: ubuntu-latest
target: linux-riscv64
zig_target: riscv64-linux-musl
ext: ""
- os: macos-latest
target: macos-aarch64
zig_target: aarch64-macos
ext: ""
- os: macos-latest
target: macos-x86_64
zig_target: x86_64-macos
ext: ""
- os: windows-latest
target: windows-x86_64
zig_target: x86_64-windows
ext: ".exe"
- os: windows-latest
target: windows-aarch64
zig_target: aarch64-windows
ext: ".exe"
steps:
- uses: actions/checkout@v4
- name: Install Zig 0.15.2
uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: ui/package-lock.json
- name: Resolve build version
id: version
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "value=dev" >> "$GITHUB_OUTPUT"
fi
- name: Set UI version from tag
if: startsWith(github.ref, 'refs/tags/v')
env:
BUILD_VERSION: ${{ steps.version.outputs.value }}
run: npm --prefix ui version "$BUILD_VERSION" --no-git-tag-version --allow-same-version
- name: Build ReleaseSmall
run: zig build -Doptimize=ReleaseSmall -Dversion=${{ steps.version.outputs.value }} ${{ matrix.zig_target && format('-Dtarget={0}', matrix.zig_target) || '' }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nullhub-${{ matrix.target }}
path: zig-out/bin/nullhub${{ matrix.ext }}
source:
name: Prepare source archive
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: ui/package-lock.json
- name: Build embedded UI assets
env:
TAG_VERSION: ${{ github.ref_name }}
run: |
npm --prefix ui ci --no-audit --no-fund
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
npm --prefix ui version "${TAG_VERSION#v}" --no-git-tag-version --allow-same-version
fi
npm --prefix ui run build
- name: Create source archive
run: |
archive_name="nullhub-source-${GITHUB_REF_NAME}.tar.gz"
tar \
--exclude='.git' \
--exclude='.zig-cache' \
--exclude='zig-out' \
--exclude='.generated_ui_assets.zig' \
--exclude='ui/node_modules' \
--exclude='ui/.svelte-kit' \
--exclude='nullhub-source-*.tar.gz' \
-czf "${archive_name}" .
echo "ARCHIVE_NAME=${archive_name}" >> "$GITHUB_ENV"
- name: Upload source archive
uses: actions/upload-artifact@v4
with:
name: nullhub-source
path: ${{ env.ARCHIVE_NAME }}
release:
needs: [build, source]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
- name: Rename binaries
run: |
mv nullhub-linux-x86_64/nullhub nullhub-linux-x86_64.bin
mv nullhub-linux-aarch64/nullhub nullhub-linux-aarch64.bin
mv nullhub-linux-riscv64/nullhub nullhub-linux-riscv64.bin
mv nullhub-macos-aarch64/nullhub nullhub-macos-aarch64.bin
mv nullhub-macos-x86_64/nullhub nullhub-macos-x86_64.bin
mv nullhub-windows-x86_64/nullhub.exe nullhub-windows-x86_64.exe
mv nullhub-windows-aarch64/nullhub.exe nullhub-windows-aarch64.exe
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
nullhub-linux-x86_64.bin
nullhub-linux-aarch64.bin
nullhub-linux-riscv64.bin
nullhub-macos-aarch64.bin
nullhub-macos-x86_64.bin
nullhub-windows-x86_64.exe
nullhub-windows-aarch64.exe
nullhub-source/*.tar.gz
generate_release_notes: true
docker:
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{raw}}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max