Skip to content

Commit 3704fa7

Browse files
authored
Merge pull request #819 from hakman/tag-releases
Tag releases via PR
2 parents 30e04d4 + 27dcab4 commit 3704fa7

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

.github/workflows/tag-release.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: tag-release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- version.txt
9+
10+
jobs:
11+
tag:
12+
if: ${{ github.repository == 'kubernetes/node-problem-detector' }}
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- run: /usr/bin/git config --global user.email [email protected]
21+
- run: /usr/bin/git config --global user.name 'GitHub Actions Release Tagger'
22+
- run: hack/tag-release.sh
23+
id: tag_release
24+
outputs:
25+
release_tag: ${{ steps.tag_release.outputs.release_tag }}

hack/tag-release.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash -xe
2+
3+
# Copyright 2023 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
VERSION=$(cat version.txt)
18+
19+
if [[ ! "${VERSION}" =~ ^v([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then
20+
echo "Version ${VERSION} must be 'X.Y.Z', 'X.Y.Z-alpha.N', or 'X.Y.Z-beta.N'"
21+
exit 1
22+
fi
23+
24+
if [ "$(git tag -l "${VERSION}")" ]; then
25+
echo "Tag ${VERSION} already exists"
26+
exit 1
27+
fi
28+
29+
git tag -a -m "Release ${VERSION}" "${VERSION}"
30+
git push origin "${VERSION}"
31+
32+
echo "release_tag=refs/tags/${VERSION}" >> $GITHUB_OUTPUT

version.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.8.15

0 commit comments

Comments
 (0)