From aec1c74025eb000168d873e683a728dc219ba30c Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Thu, 21 Sep 2023 05:18:19 +0300 Subject: [PATCH 1/2] Tag releases via PR --- .github/workflows/tag-release.yml | 25 ++++++++++++++++++++++++ hack/tag-release.sh | 32 +++++++++++++++++++++++++++++++ version.txt | 1 + 3 files changed, 58 insertions(+) create mode 100644 .github/workflows/tag-release.yml create mode 100755 hack/tag-release.sh create mode 100644 version.txt diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 000000000..19ac28e91 --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,25 @@ +name: tag-release + +on: + push: + branches: + - master + paths: + - version.txt + +jobs: + tag: + if: ${{ github.repository == 'kubernetes/node-problem-detector' }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: /usr/bin/git config --global user.email actions@github.com + - run: /usr/bin/git config --global user.name 'GitHub Actions Release Tagger' + - run: hack/tag-release.sh + id: tag_release + outputs: + release_tag: ${{ steps.tag_release.outputs.release_tag }} diff --git a/hack/tag-release.sh b/hack/tag-release.sh new file mode 100755 index 000000000..a06bd0139 --- /dev/null +++ b/hack/tag-release.sh @@ -0,0 +1,32 @@ +#!/bin/bash -xe + +# Copyright 2023 The Kubernetes Authors. +# +# 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. + +VERSION=$(cat version.txt) + +if [[ ! "${VERSION}" =~ ^([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then + echo "Version ${VERSION} must be 'X.Y.Z', 'X.Y.Z-alpha.N', or 'X.Y.Z-beta.N'" + exit 1 +fi + +if [ "$(git tag -l "v${VERSION}")" ]; then + echo "Tag v${VERSION} already exists" + exit 1 +fi + +git tag -a -m "Release ${VERSION}" "v${VERSION}" +git push origin "v${VERSION}" + +echo "release_tag=refs/tags/v${VERSION}" >> $GITHUB_OUTPUT diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..7d87d9947 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.8.15 From 27dcab4ba58786ca7cbcff00a62b8f7c1725fe16 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Mon, 25 Sep 2023 06:16:43 +0200 Subject: [PATCH 2/2] Prefix version with "v" --- hack/tag-release.sh | 12 ++++++------ version.txt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hack/tag-release.sh b/hack/tag-release.sh index a06bd0139..d9ff3e7e6 100755 --- a/hack/tag-release.sh +++ b/hack/tag-release.sh @@ -16,17 +16,17 @@ VERSION=$(cat version.txt) -if [[ ! "${VERSION}" =~ ^([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then +if [[ ! "${VERSION}" =~ ^v([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then echo "Version ${VERSION} must be 'X.Y.Z', 'X.Y.Z-alpha.N', or 'X.Y.Z-beta.N'" exit 1 fi -if [ "$(git tag -l "v${VERSION}")" ]; then - echo "Tag v${VERSION} already exists" +if [ "$(git tag -l "${VERSION}")" ]; then + echo "Tag ${VERSION} already exists" exit 1 fi -git tag -a -m "Release ${VERSION}" "v${VERSION}" -git push origin "v${VERSION}" +git tag -a -m "Release ${VERSION}" "${VERSION}" +git push origin "${VERSION}" -echo "release_tag=refs/tags/v${VERSION}" >> $GITHUB_OUTPUT +echo "release_tag=refs/tags/${VERSION}" >> $GITHUB_OUTPUT diff --git a/version.txt b/version.txt index 7d87d9947..ad9da7113 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.8.15 +v0.8.15