Skip to content

Commit dd1a640

Browse files
committed
Add changie based release workflow
1 parent 66584dd commit dd1a640

7 files changed

Lines changed: 241 additions & 0 deletions

File tree

.changes/header.tpl.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
6+
and is generated by [Changie](https://github.com/miniscruff/changie).

.changes/unreleased/.gitkeep

Whitespace-only changes.

.changie.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
changesDir: .changes
2+
unreleasedDir: unreleased
3+
headerPath: header.tpl.md
4+
changelogPath: CHANGELOG.md
5+
versionExt: md
6+
versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}'
7+
kindFormat: '### {{.Kind}}'
8+
kinds:
9+
- label: Improvements
10+
auto: minor
11+
- label: Bug Fixes
12+
auto: patch
13+
key: bug-fixes
14+
fragmentFileFormat: '{{.Component}}-{{.Kind}}-{{.Custom.PR}}'
15+
components:
16+
- language-host
17+
- converter
18+
- codegen
19+
- runtime
20+
changeFormat: '- [{{.Component}}] {{.Body}} [#{{.Custom.PR}}](https://github.com/pulumi-labs/pulumi-hcl/pull/{{.Custom.PR}})'
21+
custom:
22+
- key: PR
23+
label: GitHub Pull Request or Issue Number
24+
type: int
25+
newlines:
26+
afterVersion: 1
27+
afterChange: 1
28+
afterKind: 1
29+
afterChangelogHeader: 1
30+
endOfVersion: 1
31+
envPrefix: CHANGIE_

.github/workflows/changelog.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Verify changelog
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
check-changelog:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Get latest version recorded in .changes
16+
id: latest
17+
uses: miniscruff/changie-action@v2
18+
continue-on-error: true
19+
with:
20+
args: latest
21+
- name: Verify unreleased is empty when latest version is unreleased
22+
env:
23+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
LATEST: ${{ steps.latest.outputs.output }}
25+
run: |
26+
# No versions batched yet — nothing to verify.
27+
if [ -z "$LATEST" ]; then
28+
exit 0
29+
fi
30+
# If the version recorded by changie hasn't been released yet then
31+
# we're about to release it, so .changes/unreleased must be empty.
32+
if ! gh release view "$LATEST" >/dev/null 2>&1; then
33+
if [ -n "$(ls .changes/unreleased 2>/dev/null | grep -v '^\.gitkeep$' || true)" ]; then
34+
echo "Unreleased changes exist while $LATEST has not been published yet."
35+
echo "Either publish $LATEST first or wait for it to ship before adding new entries."
36+
exit 1
37+
fi
38+
fi

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
branches: [master]
9+
paths: [CHANGELOG.md]
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
submodules: true
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
- name: Get the latest version
23+
id: latest
24+
uses: miniscruff/changie-action@v2
25+
with:
26+
args: latest
27+
- name: Add env vars
28+
run: |
29+
LATEST='${{ steps.latest.outputs.output }}'
30+
if [ -z "$LATEST" ]; then
31+
echo "changie latest produced no version; nothing to release."
32+
exit 1
33+
fi
34+
echo "GORELEASER_CURRENT_TAG=$LATEST" >> "$GITHUB_ENV"
35+
echo "RELEASE_NOTES_PATH=.changes/$LATEST.md" >> "$GITHUB_ENV"
36+
- name: Check if release tag already exists
37+
id: check-release
38+
run: |
39+
git fetch --tags --quiet
40+
if [ -z "$(git tag -l "${GORELEASER_CURRENT_TAG}")" ]; then
41+
echo "exists=false" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "exists=true" >> "$GITHUB_OUTPUT"
44+
fi
45+
- name: Create and push tag
46+
if: steps.check-release.outputs.exists == 'false'
47+
run: |
48+
git tag "${GORELEASER_CURRENT_TAG}"
49+
git push origin "${GORELEASER_CURRENT_TAG}"
50+
- name: Run GoReleaser
51+
if: steps.check-release.outputs.exists == 'false'
52+
uses: goreleaser/goreleaser-action@v6
53+
with:
54+
version: latest
55+
args: release --clean --release-notes=${{ env.RELEASE_NOTES_PATH }}
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: 2
2+
3+
builds:
4+
- id: pulumi-language-hcl
5+
binary: pulumi-language-hcl
6+
main: ./cmd/pulumi-language-hcl
7+
env:
8+
- CGO_ENABLED=0
9+
- GO111MODULE=on
10+
goos:
11+
- darwin
12+
- windows
13+
- linux
14+
goarch:
15+
- amd64
16+
- arm64
17+
mod_timestamp: '{{ .CommitTimestamp }}'
18+
flags:
19+
- -trimpath
20+
ldflags:
21+
- -w -s -X github.com/pulumi-labs/pulumi-hcl/pkg/version.Version={{.Tag}}
22+
23+
- id: pulumi-converter-hcl
24+
binary: pulumi-converter-hcl
25+
main: ./cmd/pulumi-converter-hcl
26+
env:
27+
- CGO_ENABLED=0
28+
- GO111MODULE=on
29+
goos:
30+
- darwin
31+
- windows
32+
- linux
33+
goarch:
34+
- amd64
35+
- arm64
36+
mod_timestamp: '{{ .CommitTimestamp }}'
37+
flags:
38+
- -trimpath
39+
ldflags:
40+
- -w -s -X github.com/pulumi-labs/pulumi-hcl/pkg/version.Version={{.Tag}}
41+
42+
archives:
43+
- id: pulumi-language-hcl
44+
builds:
45+
- pulumi-language-hcl
46+
name_template: "pulumi-language-hcl-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
47+
- id: pulumi-converter-hcl
48+
builds:
49+
- pulumi-converter-hcl
50+
name_template: "pulumi-converter-hcl-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
51+
52+
snapshot:
53+
version_template: "{{ .Tag }}-SNAPSHOT"
54+
55+
checksum:
56+
name_template: 'checksums.txt'
57+
58+
release:
59+
mode: keep-existing
60+
61+
changelog:
62+
disable: true

CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Contributing
2+
3+
## Release process
4+
5+
Releases are driven by [changie](https://changie.dev) and [GoReleaser](https://goreleaser.com). The flow is:
6+
7+
1. **Add a changelog fragment with every user-visible PR.**
8+
9+
Run `changie new` from the repo root and answer the prompts:
10+
- **Component**: one of `language-host`, `converter`, `codegen`, `runtime`.
11+
- **Kind**: `Improvements` (auto-bumps minor) or `Bug Fixes` (auto-bumps patch).
12+
- **Body**: a short description written from the user's perspective.
13+
- **PR**: the GitHub PR number this change ships in.
14+
15+
This writes a file under `.changes/unreleased/`. Commit it with your PR.
16+
17+
2. **Cut a release PR.**
18+
19+
When you're ready to ship, run:
20+
21+
```sh
22+
changie batch auto # or an explicit version, e.g. `changie batch v0.2.0`
23+
changie merge
24+
```
25+
26+
`changie batch` consumes everything in `.changes/unreleased/` and writes
27+
`.changes/<version>.md`. `changie merge` rewrites the top-level `CHANGELOG.md` from the
28+
header template plus all batched versions. Open a PR titled "Release `<version>`" with
29+
just those two changes.
30+
31+
3. **Merge the release PR to `master`.**
32+
33+
The `Release` workflow fires on any push to `master` that touches `CHANGELOG.md`. It:
34+
- reads the latest version with `changie latest`,
35+
- creates and pushes a `v<version>` git tag,
36+
- runs GoReleaser, which builds `pulumi-language-hcl` and `pulumi-converter-hcl` for
37+
linux/darwin/windows × amd64/arm64 and publishes them to a GitHub release whose body is
38+
`.changes/<version>.md`.
39+
40+
The workflow no-ops if the tag already exists, so re-running it is safe.
41+
42+
### Versioning
43+
44+
The `auto` argument to `changie batch` picks the next version from the fragments: any
45+
`Improvements` entry bumps minor, otherwise `Bug Fixes` bumps patch. Override by passing
46+
an explicit `vX.Y.Z` when a release needs a major bump or a different version than `auto`
47+
would compute.

0 commit comments

Comments
 (0)