Skip to content

Commit a01119a

Browse files
committed
cicd: added Release workflow
1 parent 0950d56 commit a01119a

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

.github/.goreleaser.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
4+
# The lines below are called `modelines`. See `:help modeline`
5+
# Feel free to remove those if you don't want/need to use them.
6+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8+
9+
version: 2
10+
11+
before:
12+
hooks:
13+
# You may remove this if you don't use go modules.
14+
- go mod tidy
15+
# you may remove this if you don't need go generate
16+
- go generate ./...
17+
18+
builds:
19+
- env:
20+
- CGO_ENABLED=0
21+
goos:
22+
- linux
23+
- windows
24+
- darwin
25+
26+
archives:
27+
- format: tar.gz
28+
# this name template makes the OS and Arch compatible with the results of `uname`.
29+
name_template: >-
30+
{{ .ProjectName }}_
31+
{{- title .Os }}_
32+
{{- if eq .Arch "amd64" }}x86_64
33+
{{- else if eq .Arch "386" }}i386
34+
{{- else }}{{ .Arch }}{{ end }}
35+
{{- if .Arm }}v{{ .Arm }}{{ end }}
36+
# use zip for windows archives
37+
format_overrides:
38+
- goos: windows
39+
format: zip
40+
41+
brews:
42+
- repository:
43+
owner: miyamo2
44+
name: homebrew-tap
45+
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
46+
pull_request:
47+
# Whether to enable it or not.
48+
enabled: true
49+
50+
changelog:
51+
sort: asc
52+
filters:
53+
exclude:
54+
- "^docs:"
55+
- "^test:"

.github/workflows/release.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths: ["CHANGELOG.md"]
7+
8+
permissions: write-all
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
env:
14+
GO_VERSION: "1.23.0"
15+
16+
steps:
17+
- uses: Kesin11/actions-timeline@v2
18+
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ env.GO_VERSION }}
25+
cache: true
26+
cache-dependency-path: go.sum
27+
28+
- name: Extract Version
29+
id: versioning
30+
run: |
31+
VERSION="v$(sed -n 's/##\s\([0-9.]*\)\s.*/\1/p' CHANGELOG.md | head -1)"
32+
echo ::set-output name=version::$VERSION
33+
34+
- name: Extract changes from prev version
35+
run: |
36+
git fetch --prune --unshallow
37+
PRETAG=$(git tag --sort -v:refname | head -1)
38+
CURRENTTAG=${{ steps.versioning.outputs.version }}
39+
echo "## What's Changed in ${CURRENTTAG}" > /tmp/diff-changelog.md
40+
if [ -z "$PRETAG" ]
41+
then
42+
cat CHANGELOG.md | sed -e 's/##\s[0-9.]*\s.*//g' >> /tmp/diff-changelog.md
43+
else
44+
git diff $PRETAG..${{ github.sha }} -- CHANGELOG.md | grep -E '^\+' | grep -v '+++' | sed -e 's/^\+//g' | sed -e 's/##\s[0-9.]*\s.*//g' | sed -e '/^$/d' >> /tmp/diff-changelog.md
45+
echo "" >> /tmp/diff-changelog.md
46+
echo "**Full Changelog**: https://github.com/miyamo2/kubectl-create-transient_configmap /compare/${PRETAG}...${CURRENTTAG}" >> /tmp/diff-changelog.md
47+
fi
48+
49+
- uses: goreleaser/goreleaser-action@v6
50+
with:
51+
workdir: .github/
52+
version: latest
53+
args: release --rm-dist --release-notes=/tmp/diff-changelog.md
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ go.work.sum
2323

2424
# env file
2525
.env
26+
27+
dist/

0 commit comments

Comments
 (0)