diff --git a/.github/workflows/node-flow-deploy-release-artifact.yaml b/.github/workflows/node-flow-deploy-release-artifact.yaml index 50e13ca7da0..c06f84f98e3 100644 --- a/.github/workflows/node-flow-deploy-release-artifact.yaml +++ b/.github/workflows/node-flow-deploy-release-artifact.yaml @@ -55,30 +55,68 @@ jobs: 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://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::" + 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 }} + 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: diff --git a/.github/workflows/node-zxc-build-release-artifact.yaml b/.github/workflows/node-zxc-build-release-artifact.yaml index bd079e5fc89..e97b2041105 100644 --- a/.github/workflows/node-zxc-build-release-artifact.yaml +++ b/.github/workflows/node-zxc-build-release-artifact.yaml @@ -147,6 +147,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: | @@ -175,9 +205,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: @@ -200,7 +227,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" diff --git a/.releaserc b/.releaserc new file mode 100644 index 00000000000..9fdf24d0c49 --- /dev/null +++ b/.releaserc @@ -0,0 +1,43 @@ +{ + "plugins": [ + "@semantic-release/commit-analyzer", + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits" + } + ], + "@semantic-release/git", + "@semantic-release/github" + ], + "verifyRelease": [ + [ + "@semantic-release/exec", + { "cmd": "echo ${nextRelease.version} > VERSION" } + ] + ], + "prepare": [ + [ + "@semantic-release/exec", + { "cmd": "./gradlew versionAsSpecified --scan -PnewVersion=${nextRelease.version}" } + ], + [ + "@semantic-release/git", + { + "assets": [ + "version.txt" + ] + } + ] + ], + "branches":[ + { + "name": "main" + }, + { + "name": "release/([0-9]+).([0-9]+)", + "channel": "${name.replace(/release\\//g, '').split('.')[0]}.${name.replace(/release\\//g, '').split('.')[1]}.x", + "range": "${name.replace(/release\\//g, '').split('.')[0]}.${name.replace(/release\\//g, '').split('.')[1]}.x" + } + ] +} \ No newline at end of file