Skip to content

Commit 376525e

Browse files
authored
ci(release): only set latest release in github when latest (argoproj#24525) (argoproj#24688)
Signed-off-by: Alexandre Gaudreault <[email protected]>
1 parent 9fa9bb8 commit 376525e

File tree

2 files changed

+49
-33
lines changed

2 files changed

+49
-33
lines changed

.github/workflows/release.yaml

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@ jobs:
3232
quay_username: ${{ secrets.RELEASE_QUAY_USERNAME }}
3333
quay_password: ${{ secrets.RELEASE_QUAY_TOKEN }}
3434

35+
setup-variables:
36+
name: Setup Release Variables
37+
if: github.repository == 'argoproj/argo-cd'
38+
runs-on: ubuntu-22.04
39+
outputs:
40+
is_pre_release: ${{ steps.var.outputs.is_pre_release }}
41+
is_latest_release: ${{ steps.var.outputs.is_latest_release }}
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0
45+
with:
46+
fetch-depth: 0
47+
token: ${{ secrets.GITHUB_TOKEN }}
48+
- name: Setup variables
49+
id: var
50+
run: |
51+
set -xue
52+
# Fetch all tag information
53+
git fetch --prune --tags --force
54+
55+
LATEST_RELEASE_TAG=$(git -c 'versionsort.suffix=-rc' tag --list --sort=version:refname | grep -v '-' | tail -n1)
56+
57+
PRE_RELEASE=false
58+
# Check if latest tag is a pre-release
59+
if echo ${{ github.ref_name }} | grep -E -- '-rc[0-9]+$';then
60+
PRE_RELEASE=true
61+
fi
62+
63+
IS_LATEST=false
64+
# Ensure latest release tag matches github.ref_name
65+
if [[ $LATEST_RELEASE_TAG == ${{ github.ref_name }} ]];then
66+
IS_LATEST=true
67+
fi
68+
echo "is_pre_release=$PRE_RELEASE" >> $GITHUB_OUTPUT
69+
echo "is_latest_release=$IS_LATEST" >> $GITHUB_OUTPUT
70+
3571
argocd-image-provenance:
3672
needs: [argocd-image]
3773
permissions:
@@ -50,15 +86,17 @@ jobs:
5086

5187
goreleaser:
5288
needs:
89+
- setup-variables
5390
- argocd-image
5491
- argocd-image-provenance
5592
permissions:
5693
contents: write # used for uploading assets
5794
if: github.repository == 'argoproj/argo-cd'
5895
runs-on: ubuntu-22.04
96+
env:
97+
GORELEASER_MAKE_LATEST: ${{ needs.setup-variables.outputs.is_latest_release }}
5998
outputs:
6099
hashes: ${{ steps.hash.outputs.hashes }}
61-
62100
steps:
63101
- name: Checkout code
64102
uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0
@@ -140,7 +178,7 @@ jobs:
140178
permissions:
141179
contents: write # Needed for release uploads
142180
outputs:
143-
hashes: ${{ steps.sbom-hash.outputs.hashes}}
181+
hashes: ${{ steps.sbom-hash.outputs.hashes }}
144182
if: github.repository == 'argoproj/argo-cd'
145183
runs-on: ubuntu-22.04
146184
steps:
@@ -218,6 +256,7 @@ jobs:
218256

219257
post-release:
220258
needs:
259+
- setup-variables
221260
- argocd-image
222261
- goreleaser
223262
- generate-sbom
@@ -226,6 +265,8 @@ jobs:
226265
pull-requests: write # Needed to create PR for VERSION update.
227266
if: github.repository == 'argoproj/argo-cd'
228267
runs-on: ubuntu-22.04
268+
env:
269+
TAG_STABLE: ${{ needs.setup-variables.outputs.is_latest_release }}
229270
steps:
230271
- name: Checkout code
231272
uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0
@@ -239,27 +280,6 @@ jobs:
239280
git config --global user.email '[email protected]'
240281
git config --global user.name 'CI'
241282
242-
- name: Check if tag is the latest version and not a pre-release
243-
run: |
244-
set -xue
245-
# Fetch all tag information
246-
git fetch --prune --tags --force
247-
248-
LATEST_TAG=$(git -c 'versionsort.suffix=-rc' tag --list --sort=version:refname | tail -n1)
249-
250-
PRE_RELEASE=false
251-
# Check if latest tag is a pre-release
252-
if echo $LATEST_TAG | grep -E -- '-rc[0-9]+$';then
253-
PRE_RELEASE=true
254-
fi
255-
256-
# Ensure latest tag matches github.ref_name & not a pre-release
257-
if [[ $LATEST_TAG == ${{ github.ref_name }} ]] && [[ $PRE_RELEASE != 'true' ]];then
258-
echo "TAG_STABLE=true" >> $GITHUB_ENV
259-
else
260-
echo "TAG_STABLE=false" >> $GITHUB_ENV
261-
fi
262-
263283
- name: Update stable tag to latest version
264284
run: |
265285
git tag -f stable ${{ github.ref_name }}

.goreleaser.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ builds:
4646
archives:
4747
- id: argocd-archive
4848
builds:
49-
- argocd-cli
49+
- argocd-cli
5050
name_template: |-
5151
{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}
52-
format: binary
52+
formats: [binary]
5353

5454
checksum:
5555
name_template: 'cli_checksums.txt'
5656
algorithm: sha256
5757

5858
release:
59+
make_latest: '{{ .Env.GORELEASER_MAKE_LATEST }}'
5960
prerelease: auto
6061
draft: false
6162
header: |
@@ -85,16 +86,14 @@ release:
8586
If upgrading from a different minor version, be sure to read the [upgrading](https://argo-cd.readthedocs.io/en/stable/operator-manual/upgrading/overview/) documentation.
8687
footer: |
8788
**Full Changelog**: https://github.com/argoproj/argo-cd/compare/{{ .PreviousTag }}...{{ .Tag }}
88-
89-
<a href="https://argoproj.github.io/cd/"><img src="https://raw.githubusercontent.com/argoproj/argo-site/master/content/pages/cd/gitops-cd.png" width="25%" ></a>
9089
90+
<a href="https://argoproj.github.io/cd/"><img src="https://raw.githubusercontent.com/argoproj/argo-site/master/content/pages/cd/gitops-cd.png" width="25%" ></a>
9191
9292
snapshot: #### To be removed for PR
93-
name_template: "2.6.0"
93+
name_template: '2.6.0'
9494

9595
changelog:
96-
use:
97-
github
96+
use: github
9897
sort: asc
9998
abbrev: 0
10099
groups: # Regex use RE2 syntax as defined here: https://github.com/google/re2/wiki/Syntax.
@@ -117,7 +116,4 @@ changelog:
117116
- '^test:'
118117
- '^.*?Bump(\([[:word:]]+\))?.+$'
119118
- '^.*?\[Bot\](\([[:word:]]+\))?.+$'
120-
121-
122119
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
123-

0 commit comments

Comments
 (0)