Skip to content

Commit 23690c5

Browse files
authored
chore: update release flow to be fully automated (#304)
1 parent 05bdd62 commit 23690c5

File tree

9 files changed

+126
-38
lines changed

9 files changed

+126
-38
lines changed

.github/actions/go-test/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "go test"
2+
description: "runs go tests"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Check out repository
8+
uses: actions/[email protected]
9+
10+
- name: Set up go
11+
uses: actions/[email protected]
12+
with:
13+
# renovate: go-version
14+
go-version: 1.18.4
15+
16+
- name: Run go tests
17+
shell: bash
18+
run: |
19+
go test ./... -race -covermode=atomic -coverprofile=coverage.out
20+
21+
- name: Upload coverage to Codecov
22+
uses: codecov/codecov-action@v3
23+
with:
24+
files: coverage.out

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
name: pre-commit
22

33
on:
4-
pull_request:
54
push:
6-
branches:
7-
- main
85

96
jobs:
107
pre-commit:
118
runs-on: ubuntu-latest
129
steps:
1310
- uses: actions/[email protected]
1411

15-
- uses: actions/setup-go@v3
12+
- uses: actions/setup-go@v3.2.1
1613
with:
1714
# renovate: go-version
1815
go-version: 1.18.4

.github/workflows/go-test-and-release.yml renamed to .github/workflows/test-and-release.yml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,40 @@
1-
name: go test & release
1+
name: test & release
22

33
on:
4-
pull_request:
54
push:
6-
branches:
7-
- main
85
tags:
9-
- "*"
6+
- "v*"
107

118
permissions:
129
contents: write
1310
packages: write
1411

1512
jobs:
16-
go-test:
13+
test:
1714
runs-on: ubuntu-latest
1815
steps:
19-
- uses: actions/[email protected]
20-
21-
- uses: actions/setup-go@v3
22-
with:
23-
# renovate: go-version
24-
go-version: 1.18.4
16+
- name: Check out repository
17+
uses: actions/[email protected]
2518

2619
- name: go test
27-
run: |
28-
go test -v ./... -race -covermode=atomic -coverprofile=coverage.out
29-
30-
- name: Upload coverage to Codecov
31-
uses: codecov/codecov-action@v3
32-
with:
33-
files: coverage.out
20+
uses: ./.github/actions/go-test
3421

35-
goreleaser:
22+
release:
23+
needs: test
3624
runs-on: ubuntu-latest
37-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
38-
needs: go-test
3925
steps:
4026
- name: Checkout
41-
uses: actions/checkout@v3
27+
uses: actions/checkout@v3.0.2
4228
with:
4329
fetch-depth: 0
4430

4531
- name: Set up Go
46-
uses: actions/setup-go@v3
32+
uses: actions/setup-go@v3.2.1
4733
with:
4834
# renovate: go-version
4935
go-version: 1.18.4
5036

51-
- uses: docker/login-action@v2
37+
- uses: docker/login-action@v2.0.0
5238
with:
5339
registry: ghcr.io
5440
username: ${{ github.actor }}

.github/workflows/test-and-tag.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: test & tag
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out repository
13+
uses: actions/[email protected]
14+
15+
- name: go test
16+
uses: ./.github/actions/go-test
17+
18+
tag:
19+
runs-on: ubuntu-latest
20+
needs: test
21+
container: ghcr.io/caarlos0/svu
22+
steps:
23+
- name: Checkout
24+
uses: actions/[email protected]
25+
with:
26+
fetch-depth: 0
27+
token: ${{ secrets.EZ_BOT_TOKEN }}
28+
29+
- name: Tag new version
30+
run: |
31+
if [ $(git tag -l "$(svu next)") ]; then
32+
echo "Tag already exists, no release necessary"
33+
else
34+
echo "Tagging new version"
35+
git tag "$(svu next)"
36+
git push --tags
37+
fi

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "test"
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
tags-ignore:
8+
- "v*"
9+
10+
workflow_call:
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out repository
17+
uses: actions/[email protected]
18+
19+
- name: go test
20+
uses: ./.github/actions/go-test

.goreleaser.yaml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,40 @@ builds:
55
- linux
66
- windows
77
- darwin
8+
goarch:
9+
- amd64
10+
- arm64
811
ldflags:
912
- -X github.com/envelope-zero/backend/internal/router.version={{.Version}}
13+
1014
archives:
1115
- replacements:
12-
darwin: Darwin
13-
linux: Linux
14-
windows: Windows
15-
386: i386
1616
amd64: x86_64
17-
checksum:
18-
name_template: "checksums.txt"
17+
1918
snapshot:
2019
name_template: "{{ incpatch .Version }}-next"
20+
2121
changelog:
22-
sort: asc
22+
use: github
23+
groups:
24+
- title: Features
25+
regexp: "^.*feat[(\\w)]*:+.*$"
26+
order: 0
27+
28+
- title: "Bug fixes"
29+
regexp: "^.*fix[(\\w)]*:+.*$"
30+
order: 1
31+
32+
- title: Others
33+
order: 2
34+
35+
- title: "Dependency updates"
36+
regexp: "^.*chore(deps):+.*$"
37+
order: 3
38+
2339
filters:
40+
# Commit messages matching the regexp listed here will be removed from
41+
# the changelog
2442
exclude:
2543
- "^docs:"
2644
- "^test:"

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Please do:
3333
- try to add tests for everything you add to the codebase. If you're unsure about how to test, please open a pull request and ask for input so we can work on it together!
3434
- add regression tests for bug fixes
3535

36+
## Releases
37+
38+
Releases are fully automated and happen on every feature and bug fix that is merged into the `main` branch.
39+
40+
Maintainers can manually trigger the release of a new version by creating the corresponding tag and pushing it. This is used to release new versions that only contain updates of dependencies.
41+
3642
## Common errors
3743

3844
### pre-commit fails in GitHub action

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ devserver:
1515

1616
.PHONY: test
1717
test:
18-
go test ./... -covermode=count -coverprofile=coverage.out -count=1
18+
go test ./... -covermode=atomic -coverprofile=coverage.out -count=1
1919

2020
.PHONY: coverage
2121
coverage: test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ingress:
8282
8383
## Supported Versions
8484
85-
This project is under heavy development. Therefore, only the latest release is supported.
85+
As the backend is constantly developed, only the latest minor version is supported (versions are `MAJOR.MINOR.PATCH`). If you encounter an issue, please update to the latest version of the backend and verify that it still exists in that version.
8686

8787
Please check the [releases page](https://github.com/envelope-zero/backend/releases) for the latest release.
8888

0 commit comments

Comments
 (0)