Create a git tag for every release (#10811)

This commit is contained in:
Maurizio Vitale
2025-04-22 13:25:50 +01:00
committed by GitHub
parent 69f92bcc61
commit 068bcc89d3
4 changed files with 85 additions and 0 deletions

View File

@@ -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 });

View File

@@ -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`);
}
};