|
| 1 | +# Tag gate for a releasable build. Pushing a v* tag validates the tag, runs the |
| 2 | +# full test suite, and builds the server binaries once. Nothing is published and |
| 3 | +# nothing leaves the repo. |
| 4 | +# |
| 5 | +# The manual `Release` workflow then consumes THIS run's binary artifacts by run |
| 6 | +# ID — for both the GitHub Release and the Docker image — so a failure in any |
| 7 | +# distribution stage can be fixed and retried without repeating the tests or the |
| 8 | +# compile. |
| 9 | +# |
| 10 | +# Artifacts are retained 14 days: that is the window in which a `Release` run can |
| 11 | +# still resume from this prepare run. |
| 12 | + |
| 13 | +name: Release Prepare |
| 14 | +run-name: Release Prepare ${{ github.ref_name }} |
| 15 | + |
| 16 | +on: |
| 17 | + push: |
| 18 | + tags: |
| 19 | + - "v*" |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: release-prepare-${{ github.ref_name }} |
| 23 | + cancel-in-progress: false |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +env: |
| 29 | + CARGO_TERM_COLOR: always |
| 30 | + |
| 31 | +jobs: |
| 32 | + validate-version: |
| 33 | + uses: ./.github/workflows/release-validate.yml |
| 34 | + with: |
| 35 | + ref: ${{ github.ref_name }} |
| 36 | + |
| 37 | + # Full lint + fast suite + 3-node cluster suite. Calls test.yml directly |
| 38 | + # rather than ci.yml, whose opt-in label gate only makes sense on a PR. |
| 39 | + ci: |
| 40 | + name: CI Gate |
| 41 | + needs: validate-version |
| 42 | + uses: ./.github/workflows/test.yml |
| 43 | + |
| 44 | + build-server: |
| 45 | + name: Build server (${{ matrix.label }}) |
| 46 | + needs: [validate-version, ci] |
| 47 | + runs-on: ${{ matrix.runs-on }} |
| 48 | + strategy: |
| 49 | + fail-fast: false |
| 50 | + matrix: |
| 51 | + include: |
| 52 | + - runs-on: ubuntu-latest |
| 53 | + target: x86_64-unknown-linux-gnu |
| 54 | + label: linux-x64 |
| 55 | + - runs-on: ubuntu-24.04-arm |
| 56 | + target: aarch64-unknown-linux-gnu |
| 57 | + label: linux-arm64 |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v7 |
| 60 | + |
| 61 | + - name: Install Rust |
| 62 | + uses: dtolnay/rust-toolchain@stable |
| 63 | + with: |
| 64 | + targets: ${{ matrix.target }} |
| 65 | + |
| 66 | + - uses: Swatinem/rust-cache@v2 |
| 67 | + with: |
| 68 | + prefix-key: server-${{ matrix.target }} |
| 69 | + |
| 70 | + - name: Install system deps |
| 71 | + run: | |
| 72 | + sudo apt-get update |
| 73 | + sudo apt-get install -y --no-install-recommends \ |
| 74 | + cmake clang libclang-dev pkg-config protobuf-compiler perl \ |
| 75 | + libcurl4-openssl-dev libsasl2-dev |
| 76 | +
|
| 77 | + - name: Set version from tag |
| 78 | + run: bash scripts/ci/stamp_version.sh "${{ needs.validate-version.outputs.version }}" |
| 79 | + |
| 80 | + - name: Build server binary |
| 81 | + run: cargo build -p nodedb --release --target ${{ matrix.target }} |
| 82 | + |
| 83 | + - name: Package |
| 84 | + run: | |
| 85 | + cd target/${{ matrix.target }}/release |
| 86 | + chmod +x nodedb |
| 87 | + tar czf nodedb-${{ needs.validate-version.outputs.version }}-${{ matrix.label }}.tar.gz nodedb |
| 88 | + ls -lh nodedb-*.tar.gz |
| 89 | +
|
| 90 | + # Two artifacts per arch: the tarball ships in the GitHub Release, the |
| 91 | + # bare binary is the Docker build context. Same bytes, different shape. |
| 92 | + - uses: actions/upload-artifact@v7 |
| 93 | + with: |
| 94 | + name: server-${{ matrix.label }} |
| 95 | + path: target/${{ matrix.target }}/release/nodedb-*.tar.gz |
| 96 | + retention-days: 14 |
| 97 | + |
| 98 | + - uses: actions/upload-artifact@v7 |
| 99 | + with: |
| 100 | + name: binary-${{ matrix.label }} |
| 101 | + path: target/${{ matrix.target }}/release/nodedb |
| 102 | + retention-days: 14 |
| 103 | + |
| 104 | + summary: |
| 105 | + name: Release instructions |
| 106 | + needs: [validate-version, build-server] |
| 107 | + runs-on: ubuntu-latest |
| 108 | + steps: |
| 109 | + - name: Write summary |
| 110 | + env: |
| 111 | + VERSION: ${{ needs.validate-version.outputs.version }} |
| 112 | + REPO: ${{ github.repository }} |
| 113 | + RUN_ID: ${{ github.run_id }} |
| 114 | + run: | |
| 115 | + { |
| 116 | + echo "## Prepared v${VERSION}" |
| 117 | + echo |
| 118 | + echo "Tests passed and both server binaries are built. Publish with:" |
| 119 | + echo |
| 120 | + echo '```sh' |
| 121 | + echo "gh workflow run release.yml -R ${REPO} \\" |
| 122 | + echo " -f tag=v${VERSION} \\" |
| 123 | + echo " -f prepare_run_id=${RUN_ID}" |
| 124 | + echo '```' |
| 125 | + echo |
| 126 | + echo "If one stage fails, re-run the same command with only the" |
| 127 | + echo "remaining stages enabled (\`-f publish_crates=false\`, etc.)." |
| 128 | + echo "Nothing is recompiled." |
| 129 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments