@@ -24,11 +24,38 @@ jobs:
2424 with :
2525 fetch-depth : 0
2626
27+ - name : Set Version Variables
28+ id : vars
29+ run : |
30+ # Remove the 'refs/tags/v' prefix.
31+ VERSION_TAG=$(echo "${{ github.ref }}" | sed 's,refs/tags/v,,')
32+ echo "version_tag=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
33+
34+ - name : Validate Version Order
35+ run : |
36+ PUSHED_TAG="v${{ steps.vars.outputs.version_tag }}"
37+
38+ # Get the immediate previous tag.
39+ PREVIOUS_TAG=$(git describe --tags --abbrev=0 "${PUSHED_TAG}^" 2>/dev/null || echo "v0.0.0")
40+
41+ echo "Validating pushed tag: ${PUSHED_TAG}"
42+ echo "Comparing against previous tag: ${PREVIOUS_TAG}"
43+
44+ # Create a list of the two tags and sort them. The pushed tag must be the last one.
45+ LATEST_SORTED=$(printf "%s\n%s" "$PUSHED_TAG" "$PREVIOUS_TAG" | sort -V | tail -n1)
46+
47+ if [ "$LATEST_SORTED" != "$PUSHED_TAG" ] || [ "$PUSHED_TAG" == "$PREVIOUS_TAG" ]; then
48+ echo "::error::Validation Failed: Pushed tag '${PUSHED_TAG}' is not strictly greater than the previous tag '${PREVIOUS_TAG}'."
49+ echo "::error::This could be a typo. Did you mean to release a different version?"
50+ exit 1
51+ fi
52+
53+ echo "✅ Version validation passed."
54+
2755 - name : Create release branch
2856 run : |
29- # Extract version from tag (e.g., v0.11.0 -> 0.11)
30- VERSION=$(echo "${{ github.ref }}" | sed 's/refs\/tags\/v//' | \
31- sed 's/\.[0-9]*\(-.*\)*$//')
57+ # Extract version from tag (e.g., v0.11.0 -> 0.11 or v0.12.0-rc.1 -> 0.12)
58+ VERSION=$(echo "${{ steps.vars.outputs.version_tag }}" | cut -d'.' -f1,2)
3259 BRANCH_NAME="release-${VERSION}"
3360
3461 # Check if release branch already exists
6087 - name : Checkout copa-action repository
6188 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6289 with :
63- repository : project-copacetic/copa-action
90+ repository : ${{ github.repository_owner }}/copa-action
91+ path : copa-action
6492 ref : main
6593
6694 - name : Set up Docker
@@ -75,13 +103,15 @@ jobs:
75103
76104 - name : Build and push copa-action image with new version
77105 run : |
78- tag="$(echo "${{ github.ref }}" | tr -d 'refs/tags/v')"
79- docker buildx build --build-arg copa_version=${tag} -t ghcr.io/project-copacetic/copa-action:v"$tag" --push .
106+ tag="${{ steps.vars.outputs.version_tag }}"
107+ image_owner="${{ github.repository_owner }}"
108+ docker buildx build --build-arg copa_version=${tag} -t "ghcr.io/${image_owner}/copa-action:v${tag}" --push ./copa-action
80109
81110 - name : Checkout copa-extension repository
82111 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
83112 with :
84- repository : project-copacetic/copa-extension
113+ repository : ${{ github.repository_owner }}/copa-extension
114+ path : copa-extension
85115 ref : main
86116
87117 - name : Set up Docker for copa-extension
96126
97127 - name : Build and push copa-extension image with new version
98128 run : |
99- tag="$(echo "${{ github.ref }}" | tr -d 'refs/tags/v')"
100- docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg copa_version=${tag} -t ghcr.io/project-copacetic/copa-extension:v"$tag" container/copa-extension
129+ tag="${{ steps.vars.outputs.version_tag }}"
130+ image_owner="${{ github.repository_owner }}"
131+ docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg copa_version=${tag} -t "ghcr.io/${image_owner}/copa-extension:v${tag}" ./copa-extension/container/copa-extension
0 commit comments