Skip to content

Commit 89236be

Browse files
authored
Merge pull request #536 from nckturner/version.txt-on-0.6
Add tag workflow to release-0.6 branch
2 parents 7d2e0bd + 551ce3c commit 89236be

File tree

5 files changed

+98
-1
lines changed

5 files changed

+98
-1
lines changed

.github/workflows/tag-release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: tag-release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'release-*'
7+
paths:
8+
- version.txt
9+
10+
jobs:
11+
tag-release:
12+
if: ${{ github.repository == 'kubernetes-sigs/aws-iam-authenticator' }}
13+
runs-on: ubuntu-20.04
14+
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
- run: /usr/bin/git config --global user.email [email protected]
23+
- run: /usr/bin/git config --global user.name 'GitHub Actions Release Tagger'
24+
- run: hack/tag-release.sh
25+

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ default: bin/aws-iam-authenticator
33
PKG ?= sigs.k8s.io/aws-iam-authenticator
44
GORELEASER := $(shell command -v goreleaser 2> /dev/null)
55

6-
VERSION ?= v0.6.0
6+
VERSION ?= $(shell $(shell pwd)/hack/get-version.sh)
77
GOOS ?= $(shell go env GOOS)
88
GOARCH ?= $(shell go env GOARCH)
99
GOPROXY ?= $(shell go env GOPROXY)

hack/get-version.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash -xe
2+
3+
# Copyright 2022 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+
printerr() { echo "$@" 1>&2; }
20+
21+
if [[ ! "${VERSION}" =~ ^([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then
22+
printerr "Version ${VERSION} must be 'X.Y.Z', 'X.Y.Z-alpha.N', or 'X.Y.Z-beta.N'"
23+
exit 1
24+
fi
25+
26+
echo "v${VERSION}"

hack/tag-release.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash -xe
2+
3+
# Copyright 2022 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}" =~ ^([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+
BRANCH=$(git branch --show-current)
25+
26+
if [[ ! "${BRANCH}" =~ ^(release-)([0-9]+[.][0-9]+)$ ]]; then
27+
echo "Automatic tag creation must take place on a release branch."
28+
exit 1
29+
fi
30+
31+
BRANCH_MAJ_MIN=${BRANCH#release-}
32+
VERSION_MAJ_MIN=$(echo ${VERSION} | sed -Ee 's/-(alpha|beta)\.[0-9]+$//' | sed -Ee 's/\.[0-9]+$//')
33+
34+
if [[ ! "${BRANCH_MAJ_MIN}" = $VERSION_MAJ_MIN ]]; then
35+
echo "Major minor version of tag must match major minor version of branch."
36+
exit 1
37+
fi
38+
39+
if [ "$(git tag -l "v${VERSION}")" ]; then
40+
echo "Tag v${VERSION} already exists"
41+
exit 0
42+
fi
43+
44+
git tag -a -m "Release ${VERSION}" "v${VERSION}"
45+
git push origin "v${VERSION}"

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.6.2-alpha.0

0 commit comments

Comments
 (0)