|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | +name: Release |
| 14 | +run-name: Release ${{ inputs.tag }} |
| 15 | +on: |
| 16 | + pull_request: |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + tag: |
| 20 | + description: 'Release tag (e.g., v1.0.0)' |
| 21 | + required: true |
| 22 | + type: string |
| 23 | +concurrency: |
| 24 | + group: release |
| 25 | +jobs: |
| 26 | + validate-preconditions: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout Repository |
| 30 | + uses: actions/checkout@v6 |
| 31 | + - name: Setup Bazel |
| 32 | + uses: bazel-contrib/[email protected] |
| 33 | + with: |
| 34 | + bazelisk-cache: true |
| 35 | + disk-cache: false |
| 36 | + repository-cache: false |
| 37 | + cache-save: false |
| 38 | + - name: Validate Module Version Matches Tag |
| 39 | + var: |
| 40 | + EXPECTED_VERSION: ${{ inputs.tag }} |
| 41 | + run: | |
| 42 | + MODULE_VERSION=$(bazel mod graph --depth 1 --output json | jq -r '.version') |
| 43 | + if [ "v$MODULE_VERSION" != "$EXPECTED_VERSION" ]; then |
| 44 | + echo "::error::Module version ($MODULE_VERSION) does not match release tag ($EXPECTED_VERSION)" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + echo "✓ Module version matches release tag" |
| 48 | + build-linux: |
| 49 | + needs: validate-preconditions |
| 50 | + uses: ./.github/workflows/build_linux.yml |
| 51 | + build-qnx: |
| 52 | + needs: validate-preconditions |
| 53 | + uses: ./.github/workflows/build_qnx.yml |
| 54 | + permissions: |
| 55 | + contents: read |
| 56 | + pull-requests: read |
| 57 | + secrets: inherit |
| 58 | + coverage-report: |
| 59 | + needs: validate-preconditions |
| 60 | + uses: ./.github/workflows/coverage_report.yml |
| 61 | + create-release: |
| 62 | + needs: [validate-preconditions, build-linux, build-qnx, coverage-report] |
| 63 | + runs-on: ubuntu-latest |
| 64 | + permissions: |
| 65 | + contents: write |
| 66 | + env: |
| 67 | + COVERAGE_ARCHIVE: ${{ github.event.repository.name }}-v0.0.0-coverage |
| 68 | + steps: |
| 69 | + - name: Checkout Repository |
| 70 | + uses: actions/checkout@v6 |
| 71 | + - name: Get Current Date and Previous Release Tag |
| 72 | + env: |
| 73 | + GH_TOKEN: ${{ github.token }} |
| 74 | + run: | |
| 75 | + PREVIOUS_TAG=$(gh release view --json tagName --jq '.tagName' 2>/dev/null || echo "N/A") |
| 76 | + echo "RELEASE_DATE=$(date --rfc-3339=date)" >> $GITHUB_ENV |
| 77 | + echo "PREVIOUS_RELEASE_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV |
| 78 | + - name: Generate Release Body |
| 79 | + env: |
| 80 | + RELEASE_TAG: ${{ inputs.tag }} |
| 81 | + COMMIT_SHA: ${{ github.sha }} |
| 82 | + ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 83 | + run: | |
| 84 | + envsubst '$RELEASE_TAG $PREVIOUS_RELEASE_TAG $COMMIT_SHA $RELEASE_DATE $ACTION_RUN_URL' < .github/RELEASE_TEMPLATE.md > release_body.md |
| 85 | + - name: Download Coverage Report Artifact |
| 86 | + uses: actions/download-artifact@v7 |
| 87 | + with: |
| 88 | + name: ${{ github.event.repository.name }}_coverage_report |
| 89 | + path: ${{ env.COVERAGE_ARCHIVE }} |
| 90 | + - name: Create Coverage Report Archive |
| 91 | + run: | |
| 92 | + tar --sort=name --owner=0 --group=0 --numeric-owner \ |
| 93 | + -cJf "$COVERAGE_ARCHIVE.tar.xz" --directory="$COVERAGE_ARCHIVE" . |
| 94 | + - name: Create Draft Release |
| 95 | + uses: softprops/action-gh-release@v2 |
| 96 | + with: |
| 97 | + tag_name: "v0.0.0" # ${{ inputs.tag }} |
| 98 | + body_path: release_body.md |
| 99 | + draft: true |
| 100 | + generate_release_notes: true |
| 101 | + target_commitish: ${{ github.sha }} |
| 102 | + files: | |
| 103 | + ${{ env.COVERAGE_ARCHIVE }}.tar.xz |
0 commit comments