Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion .github/actions/nanvix-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ description: >
its environment.

inputs:
target:
description: Nanvix target architecture to build.
required: false
default: i686-nanvix
install-location:
description: Directory where LLVM (and the staged sysroot) is installed.
required: true
Expand Down Expand Up @@ -41,10 +45,36 @@ runs:
shell: bash
run: sudo ./z setup

# The pinned Nanvix release currently publishes an i686 sysroot archive.
# Its source tag also supports x86_64, so build the equivalent libc bundle
# from that exact tag until an x86_64 release archive is available.
- name: Build Nanvix x86_64 libc bundle
if: inputs.target == 'x86_64-nanvix'
shell: bash
run: |
set -euo pipefail
nanvix_tag="${Z_NANVIX_RELEASE_TAG:-$(
sed -n 's/^readonly NANVIX_RELEASE_TAG="${Z_NANVIX_RELEASE_TAG:-\([^}]*\)}"$/\1/p' z
)}"
if [[ -z "${nanvix_tag}" ]]; then
echo "Failed to read NANVIX_RELEASE_TAG from z" >&2
exit 1
fi

nanvix_src="${RUNNER_TEMP}/nanvix-${nanvix_tag}-x86_64"
git clone --depth 1 --branch "${nanvix_tag}" \
https://github.com/nanvix/nanvix.git "${nanvix_src}"
make -C "${nanvix_src}" nanvix-libc-bundle \
TARGET=x86_64 RELEASE=yes LOG_LEVEL=error -j"$(nproc)"
echo "Z_NANVIX_SRC=${nanvix_src}" >> "${GITHUB_ENV}"

# Stage 0: build and install the Clang/LLD compiler (no runtimes, no libc).
- name: Configure LLVM (stage 0)
shell: bash
run: ./z configure --install-location=${{ inputs.install-location }} --stage=0
env:
INSTALL_LOCATION: ${{ inputs.install-location }}
TARGET: ${{ inputs.target }}
run: ./z configure --install-location="${INSTALL_LOCATION}" --target="${TARGET}" --stage=0

- name: Build LLVM (stage 0)
shell: bash
Expand All @@ -65,10 +95,12 @@ runs:
env:
INSTALL_LOCATION: ${{ inputs.install-location }}
RELEASE_NAME: ${{ inputs.release-name }}
TARGET: ${{ inputs.target }}
run: |
args=(
--install-location="${INSTALL_LOCATION}"
--sysroot-location="${INSTALL_LOCATION}"
--target="${TARGET}"
--stage=1
)
if [[ -n "${RELEASE_NAME}" ]]; then
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/nanvix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ env:

jobs:
build:
name: Build and test (${{ matrix.target }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
target:
- i686-nanvix
- x86_64-nanvix

steps:
- name: Checkout code
Expand All @@ -56,6 +63,7 @@ jobs:
- name: Build and test toolchain
uses: ./.github/actions/nanvix-build
with:
target: ${{ matrix.target }}
install-location: ${{ env.INSTALL_LOCATION }}
cache-key: ${{ runner.os }}-sccache
cache-restore-keys: ${{ runner.os }}-sccache
cache-key: ${{ runner.os }}-${{ matrix.target }}-sccache
cache-restore-keys: ${{ runner.os }}-${{ matrix.target }}-sccache
111 changes: 77 additions & 34 deletions .github/workflows/nanvix-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,24 @@ env:
#==================================================================================================

jobs:
release:
prepare:
name: Prepare release
runs-on: ubuntu-24.04

permissions:
contents: write
contents: read

outputs:
exists: ${{ steps.check_release.outputs.exists }}
release_name: ${{ steps.commit_info.outputs.release_name }}
short_sha: ${{ steps.commit_info.outputs.short_sha }}
tag_name: ${{ steps.commit_info.outputs.tag_name }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Git configuration
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Get commit information
id: commit_info
run: |
Expand All @@ -92,43 +93,84 @@ jobs:
echo "exists=false" >> $GITHUB_OUTPUT
fi

#----------------------------------------------------------------------------------------------
# Build (stage 0 compiler -> stage 1 runtimes + in-source Nanvix libc)
#----------------------------------------------------------------------------------------------
build:
name: Build release (${{ matrix.target }})
needs: prepare
if: needs.prepare.outputs.exists == 'false'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
target:
- i686-nanvix
- x86_64-nanvix

permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

# Build stage 0 + stage 1, install into INSTALL_LOCATION, and run the
# build-only smoke tests. The shared build/test sequence lives in the
# nanvix-build composite action (also used by the PR CI pipeline,
# nanvix-build.yml) and runs in this job, so the installed toolchain remains
# available to the release/packaging steps below.
- name: Build and test toolchain
if: steps.check_release.outputs.exists == 'false'
uses: ./.github/actions/nanvix-build
with:
target: ${{ matrix.target }}
install-location: ${{ env.INSTALL_LOCATION }}
release-name: ${{ steps.commit_info.outputs.release_name }}
cache-key: ${{ runner.os }}-sccache-release-${{ github.sha }}
release-name: ${{ needs.prepare.outputs.release_name }}-${{ matrix.target }}
cache-key: ${{ runner.os }}-${{ matrix.target }}-sccache-release-${{ github.sha }}
cache-restore-keys: |
${{ runner.os }}-sccache-release-
${{ runner.os }}-sccache

#----------------------------------------------------------------------------------------------
# Release Artifact (tarball)
#----------------------------------------------------------------------------------------------
${{ runner.os }}-${{ matrix.target }}-sccache-release-
${{ runner.os }}-${{ matrix.target }}-sccache

# `./z release` builds the toolchain and creates the release tarball.
- name: Create release artifacts
if: steps.check_release.outputs.exists == 'false'
run: ./z release

#----------------------------------------------------------------------------------------------
# Git Tag + GitHub Release
#----------------------------------------------------------------------------------------------
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: nanvix-toolchain-${{ matrix.target }}
path: .nanvix/out/${{ needs.prepare.outputs.release_name }}-${{ matrix.target }}.tar.bz2
if-no-files-found: error

publish:
name: Publish release
needs:
- prepare
- build
if: needs.prepare.outputs.exists == 'false'
runs-on: ubuntu-24.04

permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download release artifacts
uses: actions/download-artifact@v4
with:
pattern: nanvix-toolchain-*
path: .nanvix/out
merge-multiple: true

- name: Setup Git configuration
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Create release tag
if: steps.check_release.outputs.exists == 'false'
run: |
TAG_NAME="${{ steps.commit_info.outputs.tag_name }}"
TAG_NAME="${{ needs.prepare.outputs.tag_name }}"
if git rev-parse -q --verify "refs/tags/${TAG_NAME}" >/dev/null; then
echo "Tag ${TAG_NAME} already exists locally; skipping tag creation."
else
Expand All @@ -137,22 +179,23 @@ jobs:
fi

- name: Create GitHub Release
if: steps.check_release.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.commit_info.outputs.tag_name }}
name: "${{ steps.commit_info.outputs.tag_name }}"
tag_name: ${{ needs.prepare.outputs.tag_name }}
name: "${{ needs.prepare.outputs.tag_name }}"
body: |
Automated release of the Nanvix LLVM ${{ env.LLVM_VERSION }} toolchain.

Built from commit: ${{ steps.commit_info.outputs.short_sha }}
Built from commit: ${{ needs.prepare.outputs.short_sha }}

This toolchain targets the Nanvix operating system (i686-unknown-nanvix)
and bundles the in-source Nanvix C library and headers.
These toolchains target the Nanvix operating system and bundle the
matching in-source Nanvix C library and headers.

**Artifacts:**
- Tarball: `${{ steps.commit_info.outputs.release_name }}.tar.bz2`
- i686: `${{ needs.prepare.outputs.release_name }}-i686-nanvix.tar.bz2`
- x86_64: `${{ needs.prepare.outputs.release_name }}-x86_64-nanvix.tar.bz2`
files: |
.nanvix/out/${{ steps.commit_info.outputs.release_name }}.tar.bz2
.nanvix/out/${{ needs.prepare.outputs.release_name }}-i686-nanvix.tar.bz2
.nanvix/out/${{ needs.prepare.outputs.release_name }}-x86_64-nanvix.tar.bz2
draft: false
prerelease: false
Loading
Loading