Skip to content

Commit d1cde74

Browse files
inject proposed version when running goreleaser
1 parent 0558e35 commit d1cde74

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,35 @@ name: goreleaser
55

66
on:
77
workflow_dispatch:
8-
inputs:
9-
prerelease:
10-
description: If set, publish this as a release candidate / prerelease version.
11-
type: boolean
12-
required: true
138

149
jobs:
1510
release:
11+
permissions:
12+
contents: read
1613
runs-on: ubuntu-latest
1714
steps:
1815
- name: Checkout
1916
uses: actions/checkout@v4
2017
with:
18+
# Needed otherwise we get a shallow checkout by default.
19+
# We need more so that goreleaser can find the previous version.
2120
fetch-depth: 0
2221
- name: Set up Go
2322
uses: actions/setup-go@v5
2423
with:
25-
go-version: 1.20
24+
go-version: "1.20"
25+
- name: Extract version
26+
id: extract_version
27+
run: |
28+
CMD_VERSION="$(go run ./cmd/jsonnet --version | grep -oe 'v[0-9][0-9a-z.-]*$')" &&
29+
printf "Extracted jsonnet version: %s\n" "${CMD_VERSION}" &&
30+
git tag "${CMD_VERSION}" &&
31+
printf "jsonnet_version='%s'\n" "${CMD_VERSION}" >> "${GITHUB_OUTPUT}"
2632
- name: Run GoReleaser
2733
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1
34+
env:
35+
PROPOSED_VERSION: "${{ steps.extract_version.outputs.jsonnet_version }}"
36+
GITHUB_TOKEN: "${{ github.token }}"
2837
with:
2938
version: latest
30-
args: release --rm-dist
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
args: release --clean --draft

.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ checksum:
9696
release:
9797
draft: true
9898
skip_upload: false
99+
target_commitish: "{{ .Env.PROPOSED_VERSION }}"
99100

100101
nfpms:
101102
- id: jsonnet

0 commit comments

Comments
 (0)