Nightly Release #43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Release | |
| run-name: "${{ inputs.pr && format('PR #{0} artifacts', inputs.pr) || 'Nightly Release' }}" | |
| permissions: {} | |
| on: | |
| schedule: | |
| - cron: "0 6 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| pr: | |
| description: Pull request number to build without publishing a release | |
| required: false | |
| type: string | |
| env: | |
| CARGO_TERM_COLOR: always | |
| concurrency: | |
| group: ${{ inputs.pr && format('pr-artifacts-{0}', inputs.pr) || 'nightly-release' }} | |
| cancel-in-progress: ${{ inputs.pr != '' }} | |
| jobs: | |
| build: | |
| if: github.repository == 'gakonst/nanocodex' | |
| name: build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| artifact: nanocodex-x86_64-unknown-linux-gnu | |
| - os: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| artifact: nanocodex-aarch64-unknown-linux-gnu | |
| - os: macos-14 | |
| target: aarch64-apple-darwin | |
| artifact: nanocodex-aarch64-apple-darwin | |
| - os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| artifact: nanocodex-x86_64-apple-darwin | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact: nanocodex-x86_64-pc-windows-msvc.exe | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| with: | |
| ref: ${{ inputs.pr && format('refs/pull/{0}/head', inputs.pr) || github.sha }} | |
| persist-credentials: false | |
| - name: Record exact source revision | |
| shell: bash | |
| run: echo "BUILD_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV" | |
| - uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2 | |
| with: | |
| cache-on-failure: true | |
| - name: Build nightly binary | |
| shell: bash | |
| env: | |
| TAG_NAME: ${{ inputs.pr && format('pr-{0}', inputs.pr) || 'nightly' }} | |
| run: | | |
| VERGEN_GIT_SHA="$BUILD_SHA" \ | |
| cargo build --locked --profile maxperf \ | |
| --package nanocodex-bin --bin nanocodex --features tempo \ | |
| --target ${{ matrix.target }} | |
| - name: Stage Unix artifact | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| mkdir dist | |
| cp "target/${{ matrix.target }}/maxperf/nanocodex" "dist/${{ matrix.artifact }}" | |
| - name: Stage Windows artifact | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Path dist | |
| Copy-Item "target/${{ matrix.target }}/maxperf/nanocodex.exe" "dist/${{ matrix.artifact }}" | |
| - name: Stage PR provenance and checksum | |
| if: github.event_name == 'workflow_dispatch' && inputs.pr != '' | |
| shell: bash | |
| env: | |
| ARTIFACT: ${{ matrix.artifact }} | |
| PR_NUMBER: ${{ inputs.pr }} | |
| run: | | |
| cd dist | |
| if command -v sha256sum >/dev/null 2>&1; then | |
| sha256sum "$ARTIFACT" > "$ARTIFACT.sha256" | |
| else | |
| shasum -a 256 "$ARTIFACT" > "$ARTIFACT.sha256" | |
| fi | |
| printf '{"repository":"%s","pr":%s,"sha":"%s","artifact":"%s","run_id":%s}\n' \ | |
| "$GITHUB_REPOSITORY" "$PR_NUMBER" "$BUILD_SHA" "$ARTIFACT" \ | |
| "$GITHUB_RUN_ID" > PR_BUILD.json | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: dist/* | |
| if-no-files-found: error | |
| retention-days: ${{ inputs.pr && 7 || 1 }} | |
| build-harbor: | |
| if: github.repository == 'gakonst/nanocodex' | |
| name: build Harbor static x86_64 Linux | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 45 | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| with: | |
| ref: ${{ inputs.pr && format('refs/pull/{0}/head', inputs.pr) || github.sha }} | |
| persist-credentials: false | |
| - name: Record exact source revision | |
| shell: bash | |
| run: echo "BUILD_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV" | |
| - name: Build static Harbor agent | |
| shell: bash | |
| env: | |
| TAG_NAME: ${{ inputs.pr && format('pr-{0}', inputs.pr) || 'nightly' }} | |
| run: | | |
| mkdir dist | |
| docker build \ | |
| --platform linux/amd64 \ | |
| --build-arg CARGO_PROFILE=maxperf \ | |
| --build-arg TAG_NAME="$TAG_NAME" \ | |
| --build-arg VERGEN_GIT_SHA="$BUILD_SHA" \ | |
| --file harbor_adapter/nanocodex.Dockerfile \ | |
| --target artifact \ | |
| --output type=local,dest=dist \ | |
| . | |
| mv dist/nanocodex dist/nanocodex-x86_64-unknown-linux-musl | |
| - name: Verify the Harbor artifact is portable | |
| shell: bash | |
| run: | | |
| file dist/nanocodex-x86_64-unknown-linux-musl | |
| docker run --rm \ | |
| --volume "$PWD/dist:/dist:ro" \ | |
| alpine:3.21 \ | |
| /dist/nanocodex-x86_64-unknown-linux-musl --version | |
| docker run --rm \ | |
| --volume "$PWD/dist:/dist:ro" \ | |
| ubuntu:22.04 \ | |
| /dist/nanocodex-x86_64-unknown-linux-musl --version | |
| - name: Stage PR provenance and checksum | |
| if: github.event_name == 'workflow_dispatch' && inputs.pr != '' | |
| shell: bash | |
| env: | |
| ARTIFACT: nanocodex-x86_64-unknown-linux-musl | |
| PR_NUMBER: ${{ inputs.pr }} | |
| run: | | |
| cd dist | |
| sha256sum "$ARTIFACT" > "$ARTIFACT.sha256" | |
| printf '{"repository":"%s","pr":%s,"sha":"%s","artifact":"%s","run_id":%s}\n' \ | |
| "$GITHUB_REPOSITORY" "$PR_NUMBER" "$BUILD_SHA" "$ARTIFACT" \ | |
| "$GITHUB_RUN_ID" > PR_BUILD.json | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: nanocodex-x86_64-unknown-linux-musl | |
| path: dist/* | |
| if-no-files-found: error | |
| retention-days: ${{ inputs.pr && 7 || 1 }} | |
| publish: | |
| if: >- | |
| github.repository == 'gakonst/nanocodex' && | |
| (github.event_name != 'workflow_dispatch' || inputs.pr == '') | |
| name: publish immutable and rolling nightlies | |
| needs: [build, build-harbor] | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate checksums | |
| shell: bash | |
| run: | | |
| cd dist | |
| sha256sum nanocodex-* > SHA256SUMS | |
| - name: Publish immutable and rolling releases | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| shell: bash | |
| run: | | |
| immutable_tag="nightly-${GITHUB_SHA}" | |
| short_sha="${GITHUB_SHA:0:10}" | |
| release_name="Nanocodex Nightly ($(date -u +%Y-%m-%d), ${short_sha})" | |
| notes_file=$(mktemp) | |
| { | |
| printf "Automated nightly build from [\`%s\`](https://github.com/%s/commit/%s).\n\n" "$short_sha" "$GITHUB_REPOSITORY" "$GITHUB_SHA" | |
| printf "Install it with \`nanocodex update --nightly\`.\n" | |
| } > "$notes_file" | |
| if gh release view "$immutable_tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then | |
| gh release edit "$immutable_tag" --repo "$GITHUB_REPOSITORY" \ | |
| --title "$release_name" --notes-file "$notes_file" --prerelease | |
| else | |
| gh release create "$immutable_tag" --repo "$GITHUB_REPOSITORY" \ | |
| --target "$GITHUB_SHA" --title "$release_name" \ | |
| --notes-file "$notes_file" --prerelease | |
| fi | |
| gh release upload "$immutable_tag" dist/* --repo "$GITHUB_REPOSITORY" --clobber | |
| if gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/nightly" >/dev/null 2>&1; then | |
| gh api --method PATCH "repos/${GITHUB_REPOSITORY}/git/refs/tags/nightly" \ | |
| -f sha="$GITHUB_SHA" -F force=true >/dev/null | |
| else | |
| gh api --method POST "repos/${GITHUB_REPOSITORY}/git/refs" \ | |
| -f ref='refs/tags/nightly' -f sha="$GITHUB_SHA" >/dev/null | |
| fi | |
| if gh release view nightly --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then | |
| gh release edit nightly --repo "$GITHUB_REPOSITORY" \ | |
| --target "$GITHUB_SHA" --title "Nanocodex Nightly" \ | |
| --notes-file "$notes_file" --prerelease | |
| else | |
| gh release create nightly --repo "$GITHUB_REPOSITORY" \ | |
| --title "Nanocodex Nightly" --notes-file "$notes_file" --prerelease | |
| fi | |
| gh release upload nightly dist/* --repo "$GITHUB_REPOSITORY" --clobber |