# Linux release builds for the Salt Security Hub rollout. # # Test lane: push to main or ci/**, pull requests, or manual run -> build + test + pack per # distro; prints each tarball's sha256. Nothing is uploaded. # Release lane: push a tag v* -> the same, then a draft release gets every tarball and its # .sha256, and is published only if all builds passed. # # The sha256 values are copied into the hub pillar by hand; Salt installs only files that # match them, so this workflow is not the trust anchor. # # Forgejo reads .forgejo/workflows and then ignores .github/workflows; GitHub keeps build.yml. # Builds run one at a time (max-parallel: 1) with JOBS=2 and nice so the runner host stays usable. name: release on: workflow_dispatch: push: branches: [main, "ci/**"] tags: ["v*"] pull_request: jobs: draft: if: github.ref_type == 'tag' runs-on: docker container: image: debian:trixie outputs: id: ${{ steps.create.outputs.id }} steps: - name: Create draft release id: create env: TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }} run: | apt-get update -q && apt-get install -y -q --no-install-recommends curl ca-certificates python3 >/dev/null body=$(python3 -c 'import json,os; t=os.environ["GITHUB_REF_NAME"]; print(json.dumps({"tag_name": t, "name": t, "draft": True, "body": "Linux install trees for the Security Hub canary. Verify the .sha256 files."}))') curl -sf -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \ -d "$body" "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" > release.json id=$(python3 -c 'import json; print(json.load(open("release.json"))["id"])') echo "draft release id=$id"; echo "id=$id" >> "$GITHUB_OUTPUT" build: needs: [draft] # Run on branches (draft skipped) and on tags (draft succeeded). if: ${{ !failure() && !cancelled() }} runs-on: docker strategy: max-parallel: 1 fail-fast: false matrix: include: - os: trixie image: debian:trixie - os: noble image: ubuntu:24.04 container: image: ${{ matrix.image }} env: CI: "true" JOBS: "2" steps: - name: Checkout env: TOKEN: ${{ github.token }} run: | apt-get update -q && apt-get install -y -q --no-install-recommends git ca-certificates >/dev/null git init -q . && git -c http.extraHeader="Authorization: token $TOKEN" fetch -q --depth 50 --tags \ "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" "$GITHUB_SHA" git checkout -q FETCH_HEAD git log -1 --format='building %H %s' - name: Build, test, pack run: bash packaging/ci/build-release.sh ${{ matrix.os }} dist - name: Upload to draft release if: github.ref_type == 'tag' env: TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }} RELEASE_ID: ${{ needs.draft.outputs.id }} run: | for f in dist/*; do curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@$f" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=$(basename "$f")" >/dev/null echo "uploaded $(basename "$f")" done publish: needs: [draft, build] if: github.ref_type == 'tag' runs-on: docker container: image: debian:trixie steps: - name: Publish release env: TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }} RELEASE_ID: ${{ needs.draft.outputs.id }} run: | apt-get update -q && apt-get install -y -q --no-install-recommends curl ca-certificates >/dev/null curl -sf -X PATCH -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \ -d '{"draft": false}' "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID" >/dev/null echo "published release $RELEASE_ID"