Skip to content

Commit 2a5edcf

Browse files
authored
[chore] Correctly make use of previous tag in CI (#1229)
* copy over prev tag job * add prev version to correct step * add needs
1 parent f37efa4 commit 2a5edcf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/base-ci-goreleaser.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ env:
4040
GORELEASER_PRO_VERSION: v2.12.5
4141

4242
jobs:
43+
prev-tag:
44+
outputs:
45+
PREVIOUS_RELEASE_TAG: ${{ steps.prev-tag.outputs.PREVIOUS_RELEASE_TAG }}
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49+
with:
50+
fetch-depth: 0
51+
- name: Set goreleaser last tag reference in case of non-nightly release
52+
id: prev-tag
53+
if: inputs.nightly != 'true'
54+
# find previous tag by filtering out nightly tags and binary release (OCB, OpAMP) tags and then choosing the
55+
# second to last tag (last one is the current release)
56+
run: |
57+
prev_tag=$(git tag | grep -v "cmd" | grep -v "nightly" | sort -r --version-sort | head -n 2 | tail -n 1)
58+
echo "PREVIOUS_RELEASE_TAG=$prev_tag" >> "$GITHUB_OUTPUT"
59+
4360
check-goreleaser:
4461
strategy:
4562
matrix:
@@ -67,6 +84,7 @@ jobs:
6784
- GOOS: windows
6885
GOARCH: riscv64
6986
runs-on: ${{ inputs.runner_os }}
87+
needs: prev-tag
7088
outputs:
7189
version: ${{ steps.prep.outputs.version }}
7290

@@ -161,6 +179,7 @@ jobs:
161179
GOAMD64: v1
162180
GOPPC64: power8
163181
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
182+
GORELEASER_PREVIOUS_TAG: ${{ needs.prev-tag.outputs.PREVIOUS_RELEASE_TAG }}
164183

165184
- name: Move built artifacts
166185
if: inputs.distribution == 'otelcol-contrib' && inputs.nightly != true
@@ -184,6 +203,7 @@ jobs:
184203
GOAMD64: v1
185204
GOPPC64: power8
186205
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
206+
GORELEASER_PREVIOUS_TAG: ${{ needs.prev-tag.outputs.PREVIOUS_RELEASE_TAG }}
187207

188208
- name: Print built artifacts
189209
run: cat ./distributions/${{ inputs.distribution }}/dist/**/artifacts.json

0 commit comments

Comments
 (0)