Skip to content

Commit 176203c

Browse files
authored
Added release workflow (#1299)
## What changes are proposed in this pull request? Added release workflow for the go-sdk. Until now, the releases had to be done manually, but with this workflow, the release would be triggered automatically after the tagging workflow runs. It is similar to what happens in terraform provider ## How is this tested? N/A NO_CHANGELOG=true
1 parent a4fc805 commit 176203c

2 files changed

Lines changed: 93 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
merge_group:
8+
types: [checks_requested]
9+
10+
jobs:
11+
release:
12+
runs-on:
13+
group: databricks-deco-testing-runner-group
14+
labels: ubuntu-latest-deco
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
27+
# The default cache key for this action considers only the `go.sum` file.
28+
# We include .goreleaser.yaml here to differentiate from the cache used by the push action
29+
# that runs unit tests. This job produces and uses a different cache.
30+
cache-dependency-path: |
31+
go.sum
32+
.goreleaser.yml
33+
34+
35+
- name: Write release notes to file
36+
run: |
37+
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
38+
RELEASE_NOTES_DIR=/tmp/release-notes
39+
mkdir -p "$RELEASE_NOTES_DIR"
40+
RELEASE_NOTES_FILE="$RELEASE_NOTES_DIR/release-notes.md"
41+
git for-each-ref --format='%(body)' ${{ github.ref }} > "$RELEASE_NOTES_FILE"
42+
echo "Release notes file: $RELEASE_NOTES_FILE"
43+
echo "Release notes contents:"
44+
cat "$RELEASE_NOTES_FILE"
45+
else
46+
echo "Not a release tag, skipping release notes"
47+
fi
48+
49+
- name: Run GoReleaser (Release)
50+
uses: goreleaser/goreleaser-action@v6
51+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
52+
with:
53+
version: ~> v2
54+
# Arguments cannot reference environment variables, so we write the release notes
55+
# to a well-known location and use that in the goreleaser command.
56+
args: release --clean --release-notes=/tmp/release-notes/release-notes.md
57+
env:
58+
# use GITHUB_TOKEN that is already available in secrets.GITHUB_TOKEN
59+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Run GoReleaser (Snapshot)
63+
uses: goreleaser/goreleaser-action@v6
64+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
65+
with:
66+
version: ~> v2
67+
args: release --clean --snapshot
68+
env:
69+
# use GITHUB_TOKEN that is already available in secrets.GITHUB_TOKEN
70+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod download
6+
7+
builds:
8+
- skip: true
9+
10+
# Snapshot configuration for non-release builds
11+
snapshot:
12+
version_template: "{{ .Tag }}"
13+
14+
# Changelog configuration (overridden by workflow with tag message)
15+
changelog:
16+
sort: asc
17+
filters:
18+
exclude:
19+
- '^docs:'
20+
- '^test:'
21+
22+
release: {}

0 commit comments

Comments
 (0)