diff --git a/.github/actions/create-git-tag/action.yml b/.github/actions/create-git-tag/action.yml new file mode 100644 index 0000000000..736417822b --- /dev/null +++ b/.github/actions/create-git-tag/action.yml @@ -0,0 +1,23 @@ +name: Git tag creation +description: 'Creates a git tag in the specified repository for a given commit.' + +inputs: + tagName: + description: 'The github tag to be created' + required: true + releaseNote: + description: 'The github release note to be created' + required: false + +runs: + using: 'composite' + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + name: Create git tag + env: + TAG_NAME: ${{ inputs.tagName }} + RELEASE_NOTE: ${{ inputs.releaseNote }} + with: + script: | + const createGitTag = require('./.github/actions/create-git-tag/create-git-tag.js'); + await createGitTag({ core, github, context, tagName: process.env.TAG_NAME }); diff --git a/.github/actions/create-git-tag/create-git-tag.js b/.github/actions/create-git-tag/create-git-tag.js new file mode 100644 index 0000000000..05812f5b6a --- /dev/null +++ b/.github/actions/create-git-tag/create-git-tag.js @@ -0,0 +1,42 @@ +/*! + * @license + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * 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. + */ + +module.exports = async ({ github, context, core, tagName }) => { + const tagSHA = context.payload?.after ?? context.sha; + + core.notice(`Creating a tag with title: ${tagName}, and SHA: ${tagSHA}`); + + const createdTag = await github.rest.git.createTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag: tagName, + message: 'Release note', + object: tagSHA, + type: 'commit' + }); + + const createdRef = await github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/' + tagName, + sha: createdTag.data.sha + }); + + if (createdRef.status === 201) { + core.notice(`Tag ${tagName} was created successfully`); + } +}; diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 22ffa923c2..67308a7da8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,6 +100,8 @@ jobs: release-npm: needs: [setup] + outputs: + release_version: ${{ steps.set-version.outputs.release_version }} timeout-minutes: 30 if: github.event.pull_request.merged == true || github.ref_name == 'master' || github.ref_name == 'master-patch-*' runs-on: ubuntu-latest @@ -121,6 +123,7 @@ jobs: dry-run-flag: ${{ inputs.dry-run-flag }} - uses: ./.github/actions/download-node-modules-and-artifacts - name: Set libraries versions + id: set-version run: | set -u; ./scripts/github/build/bumpversion.sh @@ -154,6 +157,21 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + create-git-tag: + runs-on: ubuntu-latest + needs: [setup, release-npm] + name: Create github tag + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 1 + - uses: './.github/actions/create-git-tag' + with: + tagName: ${{ needs.release-npm.outputs.release_version }} + propagate: needs: [release-npm] if: ${{ contains(toJson(github.event.pull_request.labels.*.name), 'hxp-upstream') }} diff --git a/scripts/update-version.sh b/scripts/update-version.sh index 922b6650aa..2c5ae5fbaa 100755 --- a/scripts/update-version.sh +++ b/scripts/update-version.sh @@ -49,6 +49,8 @@ get_next_version() { VERSION=`get_next_version $DIR/..` JS_API_VERSION=`get_next_version $DIR/../lib/js-api` +echo RELEASE_VERSION=$VERSION >> $GITHUB_OUTPUT + echo "====== New libs version: $VERSION =====" echo "====== New js-api version: $JS_API_VERSION ====="