Release with Gemini #39
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
| # Copyright The Conforma Contributors | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| --- | |
| name: Release with Gemini | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| TRACKED_PATHS: "log/ VERSION" | |
| jobs: | |
| get_info: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| latest_tag: ${{ steps.get_info.outputs.latest_tag }} | |
| latest_tag_sha: ${{ steps.get_info.outputs.latest_tag_sha }} | |
| changed: ${{ steps.get_info.outputs.changed }} | |
| next_version: ${{ steps.get_info.outputs.next_version }} | |
| changelog: ${{ steps.get_changelog.outputs.changelog }} | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
| with: | |
| egress-policy: audit | |
| disable-telemetry: true | |
| - name: Checkout code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get info | |
| id: get_info | |
| run: | | |
| set -e | |
| git fetch --tags | |
| source hack/derive-version.sh $TRACKED_PATHS | |
| echo latest_tag=$LATEST_TAG | tee -a "$GITHUB_OUTPUT" | |
| echo latest_tag_sha=$LATEST_TAG_SHA | tee -a "$GITHUB_OUTPUT" | |
| echo changed=$HAVE_CHANGED | tee -a "$GITHUB_OUTPUT" | |
| echo next_version=$NEXT_VERSION | tee -a "$GITHUB_OUTPUT" | |
| - name: Get changelog | |
| id: get_changelog | |
| run: | | |
| set -e | |
| git fetch --tags | |
| # Define a unique delimiter (e.g., EOF or a random string) | |
| DELIMITER=$(openssl rand -hex 8) | |
| # Assemble the multiline content | |
| echo "changelog<<$DELIMITER" | tee -a "$GITHUB_OUTPUT" | |
| git log ${{ steps.get_info.outputs.latest_tag_sha }}..HEAD | tee -a "$GITHUB_OUTPUT" | |
| echo "$DELIMITER" >> "$GITHUB_OUTPUT" | |
| generate_release_notes: | |
| needs: get_info | |
| if: ${{ needs.get_info.outputs.changed == 'true' && needs.get_info.outputs.changelog != '' }} | |
| timeout-minutes: 60 | |
| runs-on: ubuntu-latest | |
| permissions: {} | |
| outputs: | |
| release_notes: ${{ steps.run_gemini.outputs.summary }} | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
| with: | |
| egress-policy: audit | |
| disable-telemetry: true | |
| - name: Run Gemini | |
| id: run_gemini | |
| uses: google-github-actions/run-gemini-cli@v0 | |
| with: | |
| gemini_api_key: ${{ secrets.GEMINI_API_KEY }} | |
| settings: |- | |
| { | |
| "sandbox": false, | |
| "autoAccept": true | |
| } | |
| prompt: | | |
| Make a release notes based on all notable changes since the tag | |
| ${{needs.get_info.outputs.latest_tag}}. I will provide you with | |
| the changelog. | |
| Categorize it nicely with emojis, output as Markdown. | |
| For each change that you mention in the release notes: | |
| - Summarize the change in one line | |
| - Put jira link in the beginning of the line, if the change has a | |
| jira link in the commit message | |
| Include all changes that have jira link in the commit message. | |
| Don't create a title for the release. | |
| Preface the release notes with a brief summary of the release. | |
| The summary should also refer to changes in policies and policy rules. | |
| The changelog is following below: | |
| ${{ needs.get_info.outputs.changelog}} | |
| create_release: | |
| needs: [get_info, generate_release_notes] | |
| if: ${{ needs.get_info.outputs.changed == 'true' && needs.generate_release_notes.result == 'success' && needs.generate_release_notes.outputs.release_notes != '' }} | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
| with: | |
| egress-policy: audit | |
| disable-telemetry: true | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Tag | |
| run: | | |
| set -e | |
| git fetch --tags | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| source hack/add-auto-tag.sh | |
| git push -f --tags | |
| - name: Create a release | |
| uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2 | |
| with: | |
| name: ${{ needs.get_info.outputs.next_version }} | |
| tag_name: ${{ needs.get_info.outputs.next_version }} | |
| body: ${{ needs.generate_release_notes.outputs.release_notes}} | |
| make_latest: false | |
| generate_release_notes: false |