Skip to content

Commit e29e302

Browse files
andrewrynhardfrezbo
authored andcommitted
chore: add release workflow
Add release workflow
1 parent 4ecfd4f commit e29e302

File tree

5 files changed

+213
-1
lines changed

5 files changed

+213
-1
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This GitHub action can publish assets for release when a tag is created.
2+
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
3+
#
4+
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
5+
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
6+
# secret. If you would rather own your own GPG handling, please fork this action
7+
# or use an alternative one for key handling.
8+
#
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
10+
# in `goreleaser` to indicate this is being used in a non-interactive mode.
11+
#
12+
name: release
13+
on:
14+
push:
15+
tags:
16+
- 'v*'
17+
permissions:
18+
contents: write
19+
jobs:
20+
goreleaser:
21+
runs-on: ubuntu-latest
22+
steps:
23+
-
24+
name: Checkout
25+
uses: actions/checkout@v3
26+
-
27+
name: Unshallow
28+
run: git fetch --prune --unshallow
29+
-
30+
name: Set up Go
31+
uses: actions/setup-go@v3
32+
with:
33+
go-version-file: 'go.mod'
34+
cache: true
35+
-
36+
name: Import GPG key
37+
uses: crazy-max/ghaction-import-gpg@v5
38+
id: import_gpg
39+
with:
40+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
41+
passphrase: ${{ secrets.PASSPHRASE }}
42+
-
43+
name: Run GoReleaser
44+
uses: goreleaser/[email protected]
45+
with:
46+
version: latest
47+
args: release --rm-dist
48+
env:
49+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
50+
# GitHub sets this automatically
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
terraform-provider-talos
1+
dist
2+
terraform-provider-talos

.goreleaser.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
3+
before:
4+
hooks:
5+
# this is just an example and not a requirement for provider building/publishing
6+
- go mod tidy
7+
builds:
8+
- env:
9+
# goreleaser does not work with CGO, it could also complicate
10+
# usage by users in CI/CD systems like Terraform Cloud where
11+
# they are unable to install libraries.
12+
- CGO_ENABLED=0
13+
mod_timestamp: '{{ .CommitTimestamp }}'
14+
flags:
15+
- -trimpath
16+
ldflags:
17+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
18+
goos:
19+
- freebsd
20+
- windows
21+
- linux
22+
- darwin
23+
goarch:
24+
- amd64
25+
- '386'
26+
- arm
27+
- arm64
28+
ignore:
29+
- goos: darwin
30+
goarch: '386'
31+
binary: '{{ .ProjectName }}_v{{ .Version }}'
32+
archives:
33+
- format: zip
34+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
35+
checksum:
36+
extra_files:
37+
- glob: 'terraform-registry-manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
39+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
40+
algorithm: sha256
41+
signs:
42+
- artifacts: checksum
43+
args:
44+
# if you are using this in a GitHub action or some other automated pipeline, you
45+
# need to pass the batch flag to indicate its not interactive.
46+
- "--batch"
47+
- "--local-user"
48+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
49+
- "--output"
50+
- "${signature}"
51+
- "--detach-sign"
52+
- "${artifact}"
53+
release:
54+
extra_files:
55+
- glob: 'terraform-registry-manifest.json'
56+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
57+
# If you want to manually examine the release before its live, uncomment this line:
58+
# draft: true
59+
changelog:
60+
skip: true

hack/release.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
4+
#
5+
# Generated on 2022-09-08T16:40:48Z by kres 871f67c-dirty.
6+
7+
set -e
8+
9+
RELEASE_TOOL_IMAGE="ghcr.io/siderolabs/release-tool:latest"
10+
11+
function release-tool {
12+
docker pull "${RELEASE_TOOL_IMAGE}" >/dev/null
13+
docker run --rm -w /src -v "${PWD}":/src:ro "${RELEASE_TOOL_IMAGE}" -l -d -n -t "${1}" ./hack/release.toml
14+
}
15+
16+
function changelog {
17+
if [ "$#" -eq 1 ]; then
18+
(release-tool ${1}; echo; cat CHANGELOG.md) > CHANGELOG.md- && mv CHANGELOG.md- CHANGELOG.md
19+
else
20+
echo 1>&2 "Usage: $0 changelog [tag]"
21+
exit 1
22+
fi
23+
}
24+
25+
function release-notes {
26+
release-tool "${2}" > "${1}"
27+
}
28+
29+
function cherry-pick {
30+
if [ $# -ne 2 ]; then
31+
echo 1>&2 "Usage: $0 cherry-pick <commit> <branch>"
32+
exit 1
33+
fi
34+
35+
git checkout $2
36+
git fetch
37+
git rebase upstream/$2
38+
git cherry-pick -x $1
39+
}
40+
41+
function commit {
42+
if [ $# -ne 1 ]; then
43+
echo 1>&2 "Usage: $0 commit <tag>"
44+
exit 1
45+
fi
46+
47+
git commit -s -m "release($1): prepare release" -m "This is the official $1 release."
48+
}
49+
50+
if declare -f "$1" > /dev/null
51+
then
52+
cmd="$1"
53+
shift
54+
$cmd "$@"
55+
else
56+
cat <<EOF
57+
Usage:
58+
commit: Create the official release commit message.
59+
cherry-pick: Cherry-pick a commit into a release branch.
60+
changelog: Update the specified CHANGELOG.
61+
release-notes: Create release notes for GitHub release.
62+
EOF
63+
64+
exit 1
65+
fi
66+

hack/release.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# commit to be tagged for the new release
2+
commit = "HEAD"
3+
4+
project_name = "terraform-provider-talos"
5+
github_repo = "siderolabs/terraform-provider-talos"
6+
match_deps = "^github.com/(siderolabs/[a-zA-Z0-9-]+)$"
7+
8+
previous = "v0.1.0-alpha.2"
9+
pre_release = true
10+
11+
[notes]
12+
13+
[notes.provider]
14+
title = "Talos Provider"
15+
description = """\
16+
The Talos provider supports generating configs, applying them and bootstrap the nodes.
17+
18+
Resources supported:
19+
20+
* `talos_machine_secrets`
21+
* `talos_client_configuration`
22+
* `talos_machine_configuration_controlplane`
23+
* `talos_machine_configuration_worker`
24+
* `talos_machine_configuration_apply`
25+
* `talos_machine_bootstrap`
26+
* `talos_cluster_kubeconfig`
27+
28+
Data sources supported:
29+
30+
* `talos_client_configuration`
31+
* `talos_cluster_kubeconfig`
32+
33+
Data sources will always create a diff and might be removed in a future release.
34+
"""

0 commit comments

Comments
 (0)