-
Notifications
You must be signed in to change notification settings - Fork 3
chore(ci): Adds workflow to bump protocol buffers #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
809676f
chore(ci): Adds workflow to bump protocol buffers
dmihalcik-virtru 2eab556
Update checks.yaml
dmihalcik-virtru b59fc27
Update update-platform-branch.yaml
dmihalcik-virtru 3ceffa8
Update update-platform-branch.yaml
dmihalcik-virtru 5c23cfd
Update update-platform-branch.yaml
dmihalcik-virtru 7f522db
Update update-platform-branch.yaml
dmihalcik-virtru 7ab742c
Update update-platform-branch.yaml
dmihalcik-virtru 8b384c5
Update .github/workflows/update-platform-branch.yaml
dmihalcik-virtru 3232534
Revert "Update checks.yaml"
dmihalcik-virtru 8028c9c
Update update-platform-branch.yaml
dmihalcik-virtru 267416d
Update update-platform-branch.yaml
dmihalcik-virtru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| name: "Update Platform Branch" | ||
| # This workflow updates the platform.branch property in all pom.xml files to a new tag or branch. | ||
| # It is triggered by a manual dispatch or by a call from another workflow - notably from platform changes to protocol/go. | ||
| # This property is used to select which versions of the protocol buffer definitions to use. | ||
| # | ||
| # To test: | ||
| # `act workflow_dispatch -W ./.github/workflows/update-platform-branch.yaml --input tag=protocol/go/v0.3.1` | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 0 * * *" # Runs daily at midnight UTC | ||
| workflow_call: | ||
| inputs: | ||
| tag: | ||
| required: true | ||
| type: string | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "The new tag or branch to update the platform.branch property to use for targeting the RPC protocol buffers." | ||
| required: true | ||
| default: "protocol/go/v0.3.0" | ||
|
|
||
| jobs: | ||
| update-platform-branch: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| actions: read | ||
|
|
||
| steps: | ||
| - name: Checkout java-sdk repository | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| persist-credentials: true | ||
|
|
||
| - name: Fetch latest semver tag for protocol/go | ||
| id: fetch-latest-tag | ||
| run: | | ||
| if [ -z "${{ github.event.inputs.tag }}" ]; then | ||
| LATEST_TAG=$(git ls-remote --tags https://github.com/opentdf/platform.git | \ | ||
| grep "refs/tags/protocol/go" | \ | ||
| sed 's|.*/||' | \ | ||
| sort -V | \ | ||
| tail -n1) | ||
| echo "LATEST_TAG=$LATEST_TAG" >> "$GITHUB_ENV" | ||
| else | ||
| echo "LATEST_TAG=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV" | ||
| fi | ||
|
|
||
| - name: Check if update is needed | ||
| id: check-update | ||
| run: | | ||
| CURRENT_TAG=$(grep -oP '<platform.branch>\K.*(?=</platform.branch>)' pom.xml | head -n1) | ||
| if [ "$CURRENT_TAG" = "$LATEST_TAG" ]; then | ||
| echo "Platform branch is already up-to-date." | ||
| exit 1 | ||
| fi | ||
| echo "CURRENT_TAG=$CURRENT_TAG" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Check for existing PR | ||
| id: check-pr | ||
| run: | | ||
| EXISTING_PR=$(gh pr list --head update-platform-branch --json number --jq '.[0].number') | ||
| if [ -n "$EXISTING_PR" ]; then | ||
| echo "EXISTING_PR=$EXISTING_PR" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Check out existing PR | ||
| if: steps.check-pr.outputs.EXISTING_PR != '' | ||
| run: | | ||
| git fetch origin update-platform-branch:update-platform-branch | ||
| git checkout update-platform-branch | ||
|
|
||
| - name: Update platform.branch in pom.xml files | ||
| run: | | ||
| find . -name "pom.xml" -exec sed -i.bak "s|<platform.branch>.*</platform.branch>|<platform.branch>${LATEST_TAG}</platform.branch>|g" {} \; | ||
| CHANGED_FILES=$(find . -name "pom.xml" -exec diff -u {} {}.bak \;) | ||
| if [ -z "$CHANGED_FILES" ]; then | ||
| echo "No changes detected in pom.xml files." | tee -a $GITHUB_STEP_SUMMARY | ||
| find . -name "pom.xml.bak" -delete | ||
| exit 1 | ||
| fi | ||
| echo "The following pom.xml files were updated: $CHANGED_FILES" | ||
| find . -name "pom.xml.bak" -delete | ||
|
|
||
| - name: Create new branch | ||
| if: steps.check-pr.outputs.EXISTING_PR == '' | ||
| run: | | ||
| git checkout -b update-platform-branch | ||
|
dmihalcik-virtru marked this conversation as resolved.
|
||
| git add . | ||
| git commit -m "fix(sdk): Updates to proto version $LATEST_TAG" | ||
| git push origin update-platform-branch | ||
|
|
||
| - name: Update existing PR | ||
| if: steps.check-pr.outputs.EXISTING_PR != '' | ||
| run: | | ||
| git add . | ||
| git commit --amend --no-edit | ||
| git push origin update-platform-branch --force | ||
|
|
||
| - name: Create New PR | ||
| if: steps.check-pr.outputs.EXISTING_PR == '' | ||
| uses: peter-evans/create-pull-request@v7.0.8 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: "fix(sdk): Updates to proto version $LATEST_TAG" | ||
| branch: update-platform-branch | ||
| title: "fix(sdk): Updates to proto version $LATEST_TAG" | ||
| body: | | ||
| This PR updates the platform.branch property in all pom.xml files to the new tag or branch: $LATEST_TAG. | ||
|
|
||
| See the release: https://github.com/opentdf/platform/releases/tag/$LATEST_TAG | ||
|
|
||
| Release Notes: | ||
| $RELEASE_NOTES | ||
| labels: "automated-update" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.