|
| 1 | +# Copyright The Conforma Contributors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# SPDX-License-Identifier: Apache-2.0 |
| 16 | + |
| 17 | +--- |
| 18 | +name: Release |
| 19 | + |
| 20 | +on: |
| 21 | + workflow_dispatch: |
| 22 | + schedule: |
| 23 | + - cron: '0 9 * * 3' # every Wednesday |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +env: |
| 29 | + TRACKED_PATHS: "acceptance/ policy/" |
| 30 | + |
| 31 | +jobs: |
| 32 | + |
| 33 | + get_info: |
| 34 | + |
| 35 | + runs-on: ubuntu-latest |
| 36 | + outputs: |
| 37 | + latest_tag: ${{ steps.get_info.outputs.latest_tag }} |
| 38 | + latest_tag_sha: ${{ steps.get_info.outputs.latest_tag_sha }} |
| 39 | + changed: ${{ steps.get_info.outputs.changed }} |
| 40 | + next_version: ${{ steps.get_info.outputs.next_version }} |
| 41 | + |
| 42 | + steps: |
| 43 | + |
| 44 | + - name: Harden Runner |
| 45 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 46 | + with: |
| 47 | + egress-policy: audit |
| 48 | + disable-telemetry: true |
| 49 | + |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 52 | + with: |
| 53 | + fetch-depth: 0 |
| 54 | + |
| 55 | + - name: Get info |
| 56 | + id: get_info |
| 57 | + run: | |
| 58 | + set -e |
| 59 | + git fetch --tags |
| 60 | + source hack/derive-version.sh $TRACKED_PATHS |
| 61 | + |
| 62 | + echo latest_tag=$LATEST_TAG | tee -a "$GITHUB_OUTPUT" |
| 63 | + echo latest_tag_sha=$LATEST_TAG_SHA | tee -a "$GITHUB_OUTPUT" |
| 64 | + echo changed=$HAVE_CHANGED | tee -a "$GITHUB_OUTPUT" |
| 65 | + echo next_version=$NEXT_VERSION | tee -a "$GITHUB_OUTPUT" |
| 66 | +
|
| 67 | + generate_release_notes: |
| 68 | + |
| 69 | + needs: get_info |
| 70 | + if: needs.get_info.outputs.changed == 'true' |
| 71 | + timeout-minutes: 15 |
| 72 | + runs-on: ubuntu-latest |
| 73 | + permissions: |
| 74 | + contents: read |
| 75 | + steps: |
| 76 | + |
| 77 | + - name: Harden Runner |
| 78 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 79 | + with: |
| 80 | + egress-policy: audit |
| 81 | + disable-telemetry: true |
| 82 | + |
| 83 | + - name: Checkout |
| 84 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 85 | + with: |
| 86 | + fetch-depth: 0 |
| 87 | + |
| 88 | + - name: Fetch tags |
| 89 | + id: fetch_tags |
| 90 | + run: | |
| 91 | + git fetch --tags |
| 92 | +
|
| 93 | + - name: Generate release notes |
| 94 | + uses: google-gemini/gemini-cli-action@main |
| 95 | + with: |
| 96 | + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} |
| 97 | + version: latest |
| 98 | + settings_json: | |
| 99 | + { |
| 100 | + "sandbox": true, |
| 101 | + "autoAccept": true |
| 102 | + } |
| 103 | + prompt: | |
| 104 | + Make a list of all notable changes since the tag ${{needs.get_info.outputs.latest_tag}} |
| 105 | + and categorize it nicely with emojis, output as Markdown and a |
| 106 | + one liner of the change. Add a jira link for each change if |
| 107 | + specified in the commit message. put the link in the begining |
| 108 | + of the line. |
| 109 | + Preface the release notes with a brief summary of the release. |
| 110 | + Don't create a title for the release. |
| 111 | + Also save the release notes in a file named "release-notes.md". |
| 112 | +
|
| 113 | + - name: Upload artifact |
| 114 | + uses: actions/upload-artifact@v4 |
| 115 | + with: |
| 116 | + name: release-notes |
| 117 | + path: release-notes.md |
| 118 | + |
| 119 | + |
| 120 | + create_release: |
| 121 | + needs: [get_info, generate_release_notes] |
| 122 | + if: ${{ needs.get_info.outputs.changed == 'true' && needs.generate_release_notes.result == 'success'}} |
| 123 | + permissions: |
| 124 | + contents: write |
| 125 | + runs-on: ubuntu-latest |
| 126 | + |
| 127 | + steps: |
| 128 | + |
| 129 | + - name: Harden Runner |
| 130 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 131 | + with: |
| 132 | + egress-policy: audit |
| 133 | + disable-telemetry: true |
| 134 | + |
| 135 | + - name: Checkout |
| 136 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 137 | + with: |
| 138 | + fetch-depth: 0 |
| 139 | + |
| 140 | + - name: Tag |
| 141 | + run: | |
| 142 | + set -e |
| 143 | + git fetch --tags |
| 144 | + git config --local user.email "action@github.com" |
| 145 | + git config --local user.name "GitHub Action" |
| 146 | + |
| 147 | + source hack/add-auto-tag.sh |
| 148 | + git push -f --tags |
| 149 | +
|
| 150 | + - name: Download artifact |
| 151 | + uses: actions/download-artifact@v4 |
| 152 | + with: |
| 153 | + name: release-notes |
| 154 | + |
| 155 | + - name: Create a release |
| 156 | + uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2 |
| 157 | + with: |
| 158 | + name: ${{ needs.get_info.outputs.next_version }} |
| 159 | + tag_name: ${{ needs.get_info.outputs.next_version }} |
| 160 | + body_path: "release-notes.md" |
| 161 | + make_latest: false |
| 162 | + generate_release_notes: false |
0 commit comments