From 76999c1dcbc4b0f4cbfcf6f4c22edb4fa4fd1b20 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Tue, 13 Aug 2024 16:26:15 +0200 Subject: [PATCH 1/2] add v3 tags to action conditions Actions have several publish steps that are gated by pushes to tags starting with v2. This adds the same for tags starting with v3. Signed-off-by: Jan Fajerski --- .github/workflows/ci.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5a09a98f1..b9014e0194 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,6 +107,8 @@ jobs: if: | !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) && + !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) + && !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-')) && !(github.event_name == 'push' && github.event.ref == 'refs/heads/main') @@ -127,6 +129,8 @@ jobs: if: | (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) + || (github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-')) || (github.event_name == 'push' && github.event.ref == 'refs/heads/main') @@ -211,7 +215,10 @@ jobs: name: Publish release artefacts runs-on: ubuntu-latest needs: [test_ui, test_go, test_go_more, test_go_oldest, test_windows, golangci, codeql, build_all] - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.') + if: | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) + || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - uses: prometheus/promci@3cb0c3871f223bd5ce1226995bd52ffb314798b6 # v0.1.0 @@ -242,17 +249,26 @@ jobs: restore-keys: | ${{ runner.os }}-node- - name: Check libraries version - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.') + if: | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) + || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) run: ./scripts/ui_release.sh --check-package "$(echo ${{ github.ref_name }}|sed s/v2/v0/)" - name: build run: make assets - name: Copy files before publishing libs run: ./scripts/ui_release.sh --copy - name: Publish dry-run libraries - if: "!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.'))" + if: | + !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) + && + !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) run: ./scripts/ui_release.sh --publish dry-run - name: Publish libraries - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.') + if: | + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) + || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) run: ./scripts/ui_release.sh --publish env: # The setup-node action writes an .npmrc file with this env variable From 0f79e5e2895e0a222234356e7007e3d03a993447 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Wed, 14 Aug 2024 14:36:49 +0200 Subject: [PATCH 2/2] add scripts/get_module_version.sh This script consumes a Prometheus version (or version tag) and prints the appropriate module version. Signed-off-by: Jan Fajerski --- .github/workflows/ci.yml | 2 +- RELEASE.md | 2 +- scripts/get_module_version.sh | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 scripts/get_module_version.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9014e0194..a4788da655 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -253,7 +253,7 @@ jobs: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) - run: ./scripts/ui_release.sh --check-package "$(echo ${{ github.ref_name }}|sed s/v2/v0/)" + run: ./scripts/ui_release.sh --check-package "$(./scripts/get_module_version.sh ${{ github.ref_name }})" - name: build run: make assets - name: Copy files before publishing libs diff --git a/RELEASE.md b/RELEASE.md index 0d3f7456cd..53fdc44337 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -187,7 +187,7 @@ the Prometheus server, we use major version zero releases for the libraries. Tag the new library release via the following commands: ```bash -tag="v$(sed s/2/0/ < VERSION)" +tag="v$(./scripts/get_module_version.sh)" git tag -s "${tag}" -m "${tag}" git push origin "${tag}" ``` diff --git a/scripts/get_module_version.sh b/scripts/get_module_version.sh new file mode 100755 index 0000000000..e385587044 --- /dev/null +++ b/scripts/get_module_version.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# if no version string is passed as an argument, read VERSION file +if [ $# -eq 0 ]; then + VERSION="$(< VERSION)" +else + VERSION=$1 +fi + + +# Remove leading 'v' if present +VERSION="${VERSION#v}" + +# Extract MAJOR, MINOR, and REST +MAJOR="${VERSION%%.*}" +MINOR="${VERSION#*.}"; MINOR="${MINOR%%.*}" +REST="${VERSION#*.*.}" + +# Format and output based on MAJOR version +if [[ "$MAJOR" == "2" ]]; then + echo "0.$MINOR.$REST" +elif [[ "$MAJOR" == "3" ]]; then + printf "0.3%02d.$REST\n" "$MINOR" +fi