Skip to content
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

ci: implement semantic release process #17440

Open
wants to merge 94 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
a361d18
fix: implement semantic release with workflows and releaserc config
andrewb1269hg Jan 18, 2025
4ddc3a7
fix: Add more printouts
andrewb1269hg Jan 18, 2025
eb9d97e
fix: Fix deleting branch correctly
andrewb1269hg Jan 18, 2025
b3803f9
fix: Fix error exit when checking worktree
andrewb1269hg Jan 18, 2025
6d28519
fix: add debug for temp branch deletion
andrewb1269hg Jan 18, 2025
4fcbb4d
fix: add more debugging output
andrewb1269hg Jan 18, 2025
7e49d99
fix: add print next version step
andrewb1269hg Jan 18, 2025
15ba288
fix: remove next version printing
andrewb1269hg Jan 18, 2025
bc09303
fix: add TODO comments for steps to remove before merging to mainline
andrewb1269hg Jan 18, 2025
421f882
fix: clean up spacing
andrewb1269hg Jan 18, 2025
f207044
fix: add generate changelog step
andrewb1269hg Jan 18, 2025
9daaa94
fix: checkout the branch 14967-clean-semantic-release-workflow in pri…
andrewb1269hg Jan 18, 2025
8816e9c
fix: add branch flag to semantic release
andrewb1269hg Jan 18, 2025
2fc479c
fix: Add prune tag step
andrewb1269hg Jan 18, 2025
88b680b
fix: Add listing of git merged tags
andrewb1269hg Jan 18, 2025
ecf6d93
fix: run exactly command that is failing
andrewb1269hg Jan 18, 2025
f0d4758
fix: additional debugging
andrewb1269hg Jan 18, 2025
590d8f5
fix: comment out, add rev-parse to the semantic release branch
andrewb1269hg Jan 18, 2025
d69ce63
fix: fix the bad substitution
andrewb1269hg Jan 18, 2025
82401f5
fix: fix variable for real this time
andrewb1269hg Jan 18, 2025
76a263d
fix: add more debugging statements
andrewb1269hg Jan 18, 2025
ab0cc6b
fix: reorganize, add stashing
andrewb1269hg Jan 18, 2025
5b3f344
fix: stash an untracked file releaserc
andrewb1269hg Jan 18, 2025
fb2ac11
fix: clean up debug statements, add TODO item
andrewb1269hg Jan 18, 2025
81e4027
fix: add git status call after semantic release runs
andrewb1269hg Jan 18, 2025
1660026
fix: attempt deleting the semantic release branch called from
andrewb1269hg Jan 18, 2025
57fcaef
fix: restore branch
andrewb1269hg Jan 18, 2025
d065e96
fix: add more fetching
andrewb1269hg Jan 18, 2025
8ac1dc4
fix: update workflows for new branch, implement basic git-semver
andrewb1269hg Jan 18, 2025
b1d4b4d
fix: change implementation of git semver
andrewb1269hg Jan 18, 2025
bcfd55d
fix: add tagging and delete tag based on calculcated next version
andrewb1269hg Jan 18, 2025
3f546f6
fix: fix typo
andrewb1269hg Jan 18, 2025
f8abbf2
fix: implement log with markdown flag
andrewb1269hg Jan 18, 2025
3d8f3e1
fix: run the log command
andrewb1269hg Jan 18, 2025
614ac7f
fix: switch to explicit commit sha for git-semver, attempt convention…
andrewb1269hg Jan 18, 2025
ff6ceb3
fix: Remove the releaserc file management
andrewb1269hg Jan 18, 2025
fe1c614
fix: remove more steps
andrewb1269hg Jan 18, 2025
f0b9cac
fix: previous commit works. removing releaserc file as a test
andrewb1269hg Jan 18, 2025
0657e18
fix: Add additional printouts, clean up some steps
andrewb1269hg Jan 18, 2025
a4b346a
fix: add summary step output
andrewb1269hg Jan 18, 2025
4db1a30
fix: add a step to find current version
andrewb1269hg Jan 18, 2025
1ebf71d
fix: add another output of current version after tagging new release
andrewb1269hg Jan 18, 2025
4bdb3a4
fix: clean up summary output
andrewb1269hg Jan 18, 2025
b25cff0
fix: always delete tag
andrewb1269hg Jan 18, 2025
1d81b55
fix: remove commented out steps
andrewb1269hg Jan 21, 2025
8379549
fix: cleanup code
andrewb1269hg Jan 21, 2025
1ec491e
fix: fix summary printouts
andrewb1269hg Jan 21, 2025
8cc2659
fix: update
andrewb1269hg Jan 21, 2025
65851b3
fix: fix a problem
andrewb1269hg Jan 21, 2025
8eb4424
fix: clean up the summary output
andrewb1269hg Jan 21, 2025
d567467
fix: remove dry run flag as git-semver does not support dry run
andrewb1269hg Jan 21, 2025
8b47146
fix: remove braces from BUILD_TAG to output to github summary
andrewb1269hg Jan 21, 2025
814ba43
fix: Make a new step for the summary output
andrewb1269hg Jan 21, 2025
d5af8b2
fix: print temp branch name to summary
andrewb1269hg Jan 21, 2025
e9948d2
fix: remove duplicate printout to summary
andrewb1269hg Jan 21, 2025
1468b01
fix: uncomment import gpg key step
andrewb1269hg Jan 21, 2025
e8370ca
fix: try something else for summary
andrewb1269hg Jan 21, 2025
9141eef
fix: print out
andrewb1269hg Jan 21, 2025
6531876
fix: try one other thing for summary
andrewb1269hg Jan 21, 2025
d97718d
fix: clean up duplicate
andrewb1269hg Jan 21, 2025
a1de1c5
fix: hopefully final cleanup step on summary output
andrewb1269hg Jan 21, 2025
9a65b94
fix: replace printf with echo
andrewb1269hg Jan 21, 2025
972f5cf
fix: remove extra summary print
andrewb1269hg Jan 21, 2025
bd62eb8
fix: cleanup before merging
andrewb1269hg Jan 21, 2025
b492f3d
fix: add standard braces for shell expansions
andrewb1269hg Jan 21, 2025
fc084c1
fix: push new tag to remote
andrewb1269hg Jan 21, 2025
33b5f2e
fix: final cleanup
andrewb1269hg Jan 21, 2025
2e75556
fix: spotless
andrewb1269hg Jan 21, 2025
dddfced
fix: remove delete tag step
andrewb1269hg Jan 21, 2025
554eda8
Update .github/workflows/flow-trigger-release.yaml
andrewb1269hg Jan 23, 2025
a781dc6
Update .github/workflows/flow-trigger-release.yaml
andrewb1269hg Jan 23, 2025
3aabe78
Update .github/workflows/flow-trigger-release.yaml
andrewb1269hg Jan 23, 2025
30e5ed3
Update .github/workflows/flow-trigger-release.yaml
andrewb1269hg Jan 23, 2025
b0a1f75
Update .github/workflows/flow-trigger-release.yaml
andrewb1269hg Jan 23, 2025
8f6ec6c
Update .github/workflows/increment-next-main-release.yaml
andrewb1269hg Jan 23, 2025
ba3fa11
Update .github/workflows/increment-next-main-release.yaml
andrewb1269hg Jan 23, 2025
1cfd414
fix: add comments for why we need to use semantic release temp branch
andrewb1269hg Jan 23, 2025
ce52413
fix: rename next main release file
andrewb1269hg Jan 31, 2025
d0a6f9b
Update .github/workflows/flow-increment-next-main-release.yaml
andrewb1269hg Jan 31, 2025
20c7db5
Update .github/workflows/flow-increment-next-main-release.yaml
andrewb1269hg Jan 31, 2025
59ea4a2
Update .github/workflows/flow-increment-next-main-release.yaml
andrewb1269hg Jan 31, 2025
ae3725a
Update .github/workflows/flow-trigger-release.yaml
andrewb1269hg Jan 31, 2025
1278747
Update .github/workflows/flow-trigger-release.yaml
andrewb1269hg Jan 31, 2025
b86c3f0
Update .github/workflows/flow-increment-next-main-release.yaml
andrewb1269hg Jan 31, 2025
af44e3f
Update .github/workflows/flow-increment-next-main-release.yaml
andrewb1269hg Jan 31, 2025
55414dd
fix: remove setup node, remove update version.txt, and add version nu…
andrewb1269hg Jan 31, 2025
0b98197
fix: change to private branch instead of main for testing
andrewb1269hg Jan 31, 2025
4f28d64
fix: break workflow
andrewb1269hg Jan 31, 2025
9ae9425
fix: fix workflow
andrewb1269hg Jan 31, 2025
b8be682
fix: add setup gradle step
andrewb1269hg Feb 1, 2025
5332d31
fix: add setup java step
andrewb1269hg Feb 1, 2025
20e9563
fix: change minor version roll script back to main branch
andrewb1269hg Feb 1, 2025
cbdf390
fix: propogate error from git-semver correctly on fail
andrewb1269hg Feb 1, 2025
9f847cd
fix: update to new version of git semver action
andrewb1269hg Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 191 additions & 0 deletions .github/workflows/flow-trigger-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
##
# Copyright (C) 2025 Hedera Hashgraph, LLC
#
# 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.
##

name: "[Main] Create New Release"
on:
workflow_dispatch:
inputs:
build_number:
description: "Build Number (ex: 43 = build_00043)"
andrewb1269hg marked this conversation as resolved.
Show resolved Hide resolved
type: string
required: true

defaults:
run:
shell: bash

permissions:
id-token: write
contents: read
actions: read

jobs:
create-new-release:
name: Create New Release
runs-on: network-node-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Build Input Validation
id: validate
run: |
echo "The input is ${{ inputs.build_number }}"
if ! [[ "${{ inputs.build_number }}" =~ ^[0-9]+$ ]]; then
echo "Input is not a valid integer"
exit 1
fi
echo "Input is a valid integer: $(( ${{ inputs.build_number }} ))"

# 5-digit padding
padded_number=$(printf "%05d" ${{ inputs.build_number }})
echo "Padded number is: ${padded_number}"

# Add "build_" prefix to the padded number
build_tag="build-${padded_number}"
echo "Prefixed number is: ${build_tag}"

# Export to Github output and Github summary
BUILD_TAG=${build_tag}
echo "BUILD_TAG=${build_tag}" >> ${GITHUB_OUTPUT}
echo "Build Tag to Release: ${BUILD_TAG}" >> ${GITHUB_STEP_SUMMARY}

- name: Checkout Code
id: checkout_code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: "0"
ref: ${{ steps.validate.outputs.BUILD_TAG }}
token: ${{ secrets.GH_ACCESS_TOKEN }}

- name: Import GPG Key
uses: step-security/ghaction-import-gpg@6c8fe4d0126a59d57c21f87c9ae5dd3451fa3cca # v6.1.0
with:
git_commit_gpgsign: true
git_tag_gpgsign: true
git_user_signingkey: true
gpg_private_key: ${{ secrets.SVCS_GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.SVCS_GPG_KEY_PASSPHRASE }}

- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20

- name: Calculate Temporary Semantic Release Branch Name
andrewb1269hg marked this conversation as resolved.
Show resolved Hide resolved
id: branch_name
run: |
echo "BRANCH_NAME=temp/${{ steps.validate.outputs.BUILD_TAG }}" >> ${GITHUB_OUTPUT}
echo "The temp branch name is: ${BRANCH_NAME}"

- name: Print Temporary Branch Name
run: |
echo "The temporary branch name is: ${{ steps.branch_name.outputs.BRANCH_NAME }}"
echo "Temporary Branch Name: ${{ steps.branch_name.outputs.BRANCH_NAME }}" >> ${GITHUB_STEP_SUMMARY}

# Need to create a temporary branch so we can use the git-semver tool to create a release.
# Semantic versioning only works off branches, not tags.
- name: Create a Temporary Semantic Release Branch
run: |
echo "git checkout -b ${{ steps.branch_name.outputs.BRANCH_NAME }}"
andrewb1269hg marked this conversation as resolved.
Show resolved Hide resolved
git checkout -b ${{ steps.branch_name.outputs.BRANCH_NAME }}

- name: Echo Current Branch Name
run: |
current_branch=$(git symbolic-ref --short HEAD)
echo "Currently on branch: ${current_branch}"

- name: Push Temporary Branch to Origin
run: |
echo "Pushing branch to origin:"
git push --set-upstream origin ${{ steps.branch_name.outputs.BRANCH_NAME }}

- name: Git-Semver Setup Action
uses: DJ-BBot/setup-git-semver@7ede9a8b0c0f4cfff14e9b0a8771dbc546f2b76b # v1.0.1

- name: Identify Current Version Number
run: |
echo "Find the current version number"
current_version=$(git-semver latest)
echo "Current version is: ${current_version}"

# IF HIERO/HEDERA TRANSITIONS TO A MAJOR RELEASE NUMBER (1.0.0+)
# stable = false WILL NO LONGER BE VALID
- name: Compute Next Version Number
id: next_version
run: |
echo "Compute next version number using git-semver"
echo "next_release=$(git-semver next --stable=false)" >> ${GITHUB_OUTPUT}
echo "Next release version is: ${next_release}"

- name: Apply Tag with Calculated Next Version
run: |
echo "Applying computed version tag"
git tag --annotate v${{ steps.next_version.outputs.next_release }} --message "v${{ steps.next_version.outputs.next_release }}"
echo "Applied tag v${{ steps.next_version.outputs.next_release }}"
current_version=$(git-semver latest)
echo "Version Tag Applied: v${{ steps.next_version.outputs.next_release }}" >> ${GITHUB_STEP_SUMMARY}
echo "Current version is: ${current_version}" >> ${GITHUB_STEP_SUMMARY}

- name: Push Release Tag to Remote
run: |
echo "Pushing release tag to remote"
git push origin tag v${{ steps.next_version.outputs.next_release }}
echo "Pushed new release tag to remote"

- name: Create Release Notes with Markdown
andrewb1269hg marked this conversation as resolved.
Show resolved Hide resolved
run: |
echo git-semver log --markdown ${{ steps.next_version.outputs.next_release }}
git-semver log --markdown ${{ steps.next_version.outputs.next_release }}

- name: Clean Up git-semver
run: |
echo "Deleting git-semver directory"
rm -rf ./git-semver
echo "Successfully removed git-semver directory"

- name: View Status After Running Semantic Release
run: git status

- name: Ensure Branch Not in Use and Delete Worktree
if: always()
run: |
# Switch to main
git checkout main

# Check if the branch is associated with a worktree and remove the worktree if it exists
worktree_path=$(git worktree list | grep ${{ steps.branch_name.outputs.BRANCH_NAME }} || true)

if [ -n "$worktree_path" ]; then
echo "Removing worktree at $worktree_path"
git worktree remove "$worktree_path"
else
echo "No worktree found for branch ${{ steps.branch_name.outputs.BRANCH_NAME }}"
fi

- name: Delete the Temporary Semantic Release Branch
if: always()
run: |
echo "Deleting the temporary semantic release branch"
echo "Deleting local branch now:"
git branch -d ${{ steps.branch_name.outputs.BRANCH_NAME }}
echo "Deleted Temporary Branch from Local Runner" >> ${GITHUB_STEP_SUMMARY}

echo "Deleting remote branch now:"
git push -d origin ${{ steps.branch_name.outputs.BRANCH_NAME }}
echo "Deleted Temporary Branch from Remote" >> ${GITHUB_STEP_SUMMARY}
116 changes: 116 additions & 0 deletions .github/workflows/increment-next-main-release.yaml
andrewb1269hg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
##
# Copyright (C) 2025 Hedera Hashgraph, LLC
#
# 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.
##

name: "[Main] Prepare Next Release Version"
on:
workflow_dispatch:

defaults:
run:
shell: bash

permissions:
id-token: write
contents: write
actions: write
issues: write

jobs:
next-main-release:
name: Prepare Next Release Version
runs-on: network-node-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20

- name: Checkout Code
id: checkout_code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: "0"
ref: main
token: ${{ secrets.GH_ACCESS_TOKEN }}

- name: Import GPG Key
id: gpg_importer
uses: step-security/ghaction-import-gpg@6c8fe4d0126a59d57c21f87c9ae5dd3451fa3cca # v6.1.0
with:
git_commit_gpgsign: true
git_tag_gpgsign: true
git_user_signingkey: true
gpg_private_key: ${{ secrets.SVCS_GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.SVCS_GPG_KEY_PASSPHRASE }}

- name: Install Semantic Version Tools
id: install_semver
run: |
echo "::group::Download SemVer Binary"
sudo curl -L -o /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
echo "::endgroup::"
echo "::group::Change SemVer Binary Permissions"
sudo chmod -v +x /usr/local/bin/semver
echo "::endgroup::"
echo "::group::Show SemVer Binary Version Info"
semver --version
echo "::endgroup::"

- name: Read Current Version
id: read_version
run: |
current_version=$(cat version.txt)
echo "Current version: ${current_version}"
echo "version=${current_version}" >> ${GITHUB_OUTPUT}
printf "Current Version: ${current_version}" >> ${GITHUB_STEP_SUMMARY}

- name: Increment Minor Version
id: increment_version
run: |
# Strip the -SNAPSHOT suffix
base_version=$(semver get release ${{ steps.read_version.outputs.version }})

# Increment the minor version
new_version=$(semver bump minor ${base_version})

# Add the -SNAPSHOT suffix back
new_version="${new_version}-SNAPSHOT"

echo "New version: ${new_version}"
echo "new-version=${new_version}" >> ${GITHUB_OUTPUT}
printf "New Version: ${new_version}" >> ${GITHUB_STEP_SUMMARY}

- name: Update version.txt
run: |
echo ${{ steps.increment_version.outputs.new_version }} > version.txt

- name: Publish to Maven Central
run: |
./gradlew versionAsSpecified -PnewVersion=${{ steps.increment_version.outputs.new-version }}

- name: Add & Commit
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
with:
cwd: "."
author_name: ${{ secrets.SVCS_GIT_USER_NAME }}
author_email: ${{ secrets.SVCS_GIT_USER_EMAIL }}
commit: --signoff
message: "chore: Minor Version Roll"