-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (92 loc) · 3.4 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Release RMK using GoReleaser
on:
push:
branches:
- master
- release/*
permissions:
contents: write
env:
# AWS region of the AWS account storing images in ECR.
CORE_AWS_REGION: eu-north-1
jobs:
goreleaser:
name: Release RMK using GoReleaser
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.CORE_AWS_REGION }}
aws-access-key-id: ${{ secrets.RMK_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.RMK_AWS_SECRET_ACCESS_KEY }}
- name: Get and push new tag version
run: |
# constants for selecting branches
readonly GIT_BRANCH="${GITHUB_REF_NAME}"
readonly GITHUB_ORG="${GITHUB_REPOSITORY_OWNER}"
function resolve_release_envs() {
echo "Git commit message:"
GIT_COMMIT_MSG="$(git log -1 --pretty=format:"%s")"
echo "${GIT_COMMIT_MSG}"
if [[ ! "${GIT_COMMIT_MSG}" =~ ^Merge\ pull\ request\ #[0-9]+\ from\ ${GITHUB_ORG}/(hotfix|release)/(v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
>&2 echo "Pushes to master should be done via merges of PR requests from hotfix/vN.N.N or release/vN.N.N branches only."
>&2 echo "The expected message format (will be used for parsing a release tag):"
>&2 echo "Merge pull request #N from ${GITHUB_ORG}/hotfix/vN.N.N or ${GITHUB_ORG}/release/vN.N.N."
exit 1
fi
VERSION="${BASH_REMATCH[2]}"
echo "DISABLE_BLOB_RMK_RC=true" >> "${GITHUB_ENV}"
}
case "${GIT_BRANCH}" in
release/*)
VERSION="${GIT_BRANCH#release/}-rc"
echo "DISABLE_BLOB_RMK=true" >> "${GITHUB_ENV}"
echo "Release candidate version: ${VERSION}"
git fetch --tags &> /dev/null
if (git tag | grep "${VERSION}" &> /dev/null); then
git tag --delete "${VERSION}"
git push --delete origin "${VERSION}"
fi
;;
master)
resolve_release_envs
;;
esac
echo "Configure Git user.name and user.email."
git config user.name github-actions
git config user.email github-actions@github.com
echo "Add Git tag ${VERSION}."
git tag "${VERSION}"
git push origin "${VERSION}" -f
- name: Run GoReleaser artifact build
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: v1.23.0
args: build --clean
- name: Copy metadata RMK release
run: |
cp ./dist/metadata.json ./bin/metadata.json
{
echo 'RELEASE_NOTES<<EOF'
cat docs/release-notes.md
echo 'EOF'
} >> "${GITHUB_ENV}"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: v1.23.0
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}