diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..67fb323 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,107 @@ +name: release +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + tag: + description: Release tag (must match v) + required: true + type: string + +permissions: + contents: write + +jobs: + release: + name: release (ubuntu-24.04-arm) + runs-on: ubuntu-24.04-arm + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install build dependencies + run: sudo apt-get update && sudo apt-get install -y build-essential python3 python3-pytest libibverbs-dev + + - name: Verify release tag and notes match VERSION + id: meta + env: + INPUT_TAG: ${{ inputs.tag }} + run: | + VERSION="$(cat net-sircl/VERSION)" + TAG="${INPUT_TAG:-${GITHUB_REF_NAME}}" + EXPECTED="v${VERSION}" + if [ "$TAG" != "$EXPECTED" ]; then + echo "::error::Release tag '$TAG' does not match net-sircl/VERSION ('$EXPECTED')" + exit 1 + fi + NOTES="RELEASE_NOTES-${VERSION}.md" + if [ ! -f "$NOTES" ]; then + echo "::error::Missing release notes file '$NOTES'" + exit 1 + fi + { + echo "version=$VERSION" + echo "tag=$TAG" + echo "notes=$NOTES" + } >> "$GITHUB_OUTPUT" + + - name: Build, verify, and package + run: | + make -j2 all emu + make check check-release + make package + + - name: Verify ELF hardening on net-sircl DSO + run: | + DYNAMIC="$(readelf -d net-sircl/libnccl-net-sircl.so)" + echo "$DYNAMIC" + grep -q 'SONAME.*libnccl-net-sircl.so' <<< "$DYNAMIC" + grep -q 'BIND_NOW\|FLAGS.*BIND_NOW' <<< "$DYNAMIC" + + - name: Stage ARM64 binary, prefix tarball, source archive & SHA-256 digests + env: + VERSION: ${{ steps.meta.outputs.version }} + run: | + ASSETS="$RUNNER_TEMP/release-assets" + STAGE="$RUNNER_TEMP/net-sircl-stage" + rm -rf "$ASSETS" "$STAGE" + mkdir -p "$ASSETS" + + SO_ASSET="libnccl-net-sircl-${VERSION}-aarch64.so" + TAR_ASSET="net-sircl-${VERSION}-linux-aarch64.tar.gz" + SRC_ASSET="net-sircl-${VERSION}.tar.gz" + + install -m 0755 net-sircl/libnccl-net-sircl.so "$ASSETS/$SO_ASSET" + make install DESTDIR="$STAGE" PREFIX=/opt/net-sircl + tar --sort=name --mtime='@0' --owner=0 --group=0 --numeric-owner \ + -C "$STAGE" -czf "$ASSETS/$TAR_ASSET" opt + cp "dist/${SRC_ASSET}" "$ASSETS/$SRC_ASSET" + + ( + cd "$ASSETS" + sha256sum "$SO_ASSET" > "${SO_ASSET}.sha256" + sha256sum "$TAR_ASSET" > "${TAR_ASSET}.sha256" + sha256sum "$SRC_ASSET" > "${SRC_ASSET}.sha256" + ls -lh + ) + + - name: Publish GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ steps.meta.outputs.tag }} + VERSION: ${{ steps.meta.outputs.version }} + NOTES: ${{ steps.meta.outputs.notes }} + run: | + ASSETS="$RUNNER_TEMP/release-assets" + if gh release view "$TAG" >/dev/null 2>&1; then + gh release upload "$TAG" "$ASSETS"/* --clobber + else + gh release create "$TAG" "$ASSETS"/* \ + --title "net-sircl ${VERSION}" \ + --notes-file "$NOTES" \ + --target "$GITHUB_SHA" + fi