Skip to content

Commit

Permalink
ci(publish): goreleaser action (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
villevsv-upcloud committed Sep 28, 2023
1 parent 7dd13dd commit 0e6f95a
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 13 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish
on:
push:
tags:
- 'v*.*.*'
jobs:
publish_release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout head
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0
- name: Get tag version
id: git
run: echo "tag_version=$(make version)" >> "$GITHUB_OUTPUT"
- name: Get release notes
id: release_notes
run: make release-notes > .release_notes
- name: Run goreleaser-action
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0
with:
version: latest
args: release --clean --release-notes=.release_notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 changes: 67 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Make sure to check the documentation at https://goreleaser.com
builds:
- skip: true

changelog:
# Set this to true if you don't want any changelog at all.
#
# Warning: this will also ignore any changelog files passed via `--release-notes`,
# and will render an empty changelog.
#
# This may result in an empty release notes on GitHub/GitLab/Gitea.
#
# Templates: allowed
skip: false
sort: asc
filters:

# Commit messages matching the regexp listed here will be removed from
# the changelog
exclude:
- '^chore(docs)'
- '^ci'

release:
# Repo in which the release will be created.
# Default is extracted from the origin remote URL or empty if its private hosted.
github:
owner: UpCloudLtd
name: upcloud-go-api

# If set to true, will not auto-publish the release.
# Available only for GitHub and Gitea.
#
# Default: false
draft: true

# Whether to remove existing draft releases with the same name before creating
# a new one.
# Only effective if `draft` is set to true.
# Available only for GitHub.
#
# Default: false
# Since: v1.11
replace_existing_draft: true

# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: false

# What to do with the release notes in case there the release already exists.
#
# Valid options are:
# - `keep-existing`: keep the existing notes
# - `append`: append the current release notes to the existing notes
# - `prepend`: prepend the current release notes to the existing notes
# - `replace`: replace existing notes
#
# Default is `keep-existing`.
mode: keep-existing

# You can change the name of the release.
#
# Default: '{{.Tag}}' ('{{.PrefixedTag}}' on Pro)
# Templates: allowed
name_template: "{{.Tag}}"
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.PHONY: test
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || \
cat $(CURDIR)/.version 2> /dev/null || echo v0)

.PHONY: test
test: check-test-env
go test ./... -parallel 8

Expand All @@ -13,3 +16,17 @@ endif
ifndef UPCLOUD_GO_SDK_TEST_PASSWORD
$(error UPCLOUD_GO_SDK_TEST_PASSWORD is undefined)
endif

.PHONY: version
version:
@echo $(VERSION)

.PHONY: release-notes
release-notes: CHANGELOG_HEADER = ^\#\# \[
release-notes: CHANGELOG_VERSION = $(subst v,,$(VERSION))
release-notes:
@awk \
'/${CHANGELOG_HEADER}${CHANGELOG_VERSION}/ { flag = 1; next } \
/${CHANGELOG_HEADER}/ { if ( flag ) { exit; } } \
flag { if ( n ) { print prev; } n++; prev = $$0 }' \
CHANGELOG.md
27 changes: 15 additions & 12 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Releasing

1. Merge all your changes to the stable branch
1. If releasing a new major version, ensure that package name has been updated, e.g. if new version is `v6` package name in go.mod and every import should be `github.com/UpCloudLtd/upcloud-go-api/v6`
1. Update CHANGELOG.md
1. Add new heading with the correct version e.g. `## [v2.3.5]`
1. Update links at the bottom of the page
1. Leave “Unreleased” section at the top empty
1. Update `Version` in [upcloud/client/client.go](./upcloud/client/client.go)
1. Visit the repo [GitHub releases-page](https://github.com/UpCloudLtd/upcloud-go-api/releases) and draft a new release
1. Tag the release `vX.Y.Z` (e.g. `v2.3.5`)
1. Select the stable branch
1. Title the release “vX.Y.Z”
1. In the description of the release, paste the changes from CHANGELOG.md for this version release
1. Publish the release when you are ready
2. If releasing a new major version, ensure that package name has been updated, e.g. if new version is `v6` package name in go.mod and every import should be `github.com/UpCloudLtd/upcloud-go-api/v6`
3. Update CHANGELOG.md
1. Add new heading with the correct version e.g. `## [6.7.0]`
2. Update links at the bottom of the page
3. Leave `## Unreleased` section at the top empty
4. Update `Version` in [upcloud/client/client.go](./upcloud/client/client.go)
5. Test GoReleaser config with `goreleaser check`
6. Tag a commit with the version you want to release e.g. `v6.7.0`
7. Push the tag & commit to GitHub
- GitHub action automatically
- sets the version based on the tag
- creates a draft release to GitHub
- populates the release notes from `CHANGELOG.md` with `make release-notes`
8. Verify that [release notes](https://github.com/UpCloudLtd/upcloud-go-api/releases) are in line with `CHANGELOG.MD`
9. Publish the drafted release

0 comments on commit 0e6f95a

Please sign in to comment.