forked from TheThingsNetwork/lorawan-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (161 loc) · 6.81 KB
/
release-tag.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Tag release
on: workflow_dispatch
env:
NODE_ENV: production
jobs:
release:
name: Tag release
runs-on: ubuntu-22.04
permissions:
contents: write
id-token: write
packages: write
pull-requests: write
timeout-minutes: 60
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@v7
with:
root-reserve-mb: 20480
swap-size-mb: 4096
remove-dotnet: true
remove-android: true
remove-haskell: true
remove-codeql: true
remove-docker-images: true
- name: Check branch
run: echo "${{ github.ref_name }}" | grep -Pq '^release/v3\.\d+\.\d+$'
- name: Get version
id: version
run: |
export VERSION=$(echo ${{ github.ref_name }} | grep -Po '3\.\d+.\d+')
echo "result=$VERSION" >> $GITHUB_OUTPUT
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Insert release date into the changelog
run: |
sed -i "s/^\(## \[.*\] - \)\(unreleased\)$/\1$(date +%Y-%m-%d)/" CHANGELOG.md
set +e
git diff --exit-code --quiet CHANGELOG.md
R=$?
set -e
git config user.name "The Things Bot"
git config user.email "github@thethingsindustries.com"
if [ $R -eq 1 ]; then
git add CHANGELOG.md
git commit -m "all: Enter release date of version ${{ steps.version.outputs.result }} into the changelog"
git push
git tag v${{ steps.version.outputs.result }}
git push origin v${{ steps.version.outputs.result }}
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: "${{ secrets.AWS_REGION }}"
role-to-assume: "arn:aws:iam::${{ secrets.AWS_USER_ID }}:role/${{ secrets.AWS_ROLE_NAME }}"
role-session-name: "${{ secrets.AWS_ROLE_NAME }}-${{ github.job }}-${{ github.run_id }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: "${{ secrets.GHCR_USERNAME }}"
password: "${{ secrets.GHCR_PASSWORD }}"
- name: Update APT
run: sudo apt-get -yq update
- name: Install Snapcraft
run: sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft
- name: Create Snapcraft folders
run: |
mkdir -p $HOME/.cache/snapcraft/download
mkdir -p $HOME/.cache/snapcraft/stage-packages
- name: Install Go and Dependencies
uses: ./.github/actions/install-go-and-deps
- name: Build Mage
uses: ./.github/actions/build-mage
- name: Install Node and Dependencies
uses: ./.github/actions/install-node-and-deps
- name: Initialize device repository index cache
id: dr-index-cache
uses: actions/cache@v3
with:
path: data/lorawan-devices-index
key: dr-index-cache-${{ hashFiles('data/lorawan-devices') }}
- name: Create device repository index
run: tools/bin/mage dev:initDeviceRepo
if: steps.dr-index-cache.outputs.cache-hit != 'true'
- name: Auto-completion scripts
run: tools/bin/mage cli:autocomplete
timeout-minutes: 5
- name: Build Frontend
uses: ./.github/actions/build-frontend
with:
production-sourcemaps: "true"
- name: Check for diff
run: tools/bin/mage git:diff
- name: Generate Release Notes
run: |
awk '/^## \[${{ steps.version.outputs.result }}\]/{flag=1;next} /^## \[/{flag=0} flag' CHANGELOG.md > /tmp/release-notes.md
- name: Import the signing key
run: |
printf '%s' '${{ secrets.SIGNATURE_PASSPHRASE }}' >/tmp/gpg_passphrase
cat /tmp/gpg_passphrase | gpg --passphrase-fd 0 --no-tty --batch --import gpg_signing_key
- name: Run Goreleaser
uses: goreleaser/goreleaser-action@v4
with:
version: "v1.18.2"
args: release --config .goreleaser.release.yml --release-notes /tmp/release-notes.md --timeout 120m
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
SIGN_KEY_NAME: ${{ secrets.SIGN_KEY_NAME }}
- name: Determine if released version is latest
id: latest-version
run: |
export LATEST_TAG=$(git tag | grep -P '^v3.\d+\.\d+$' | sort -V | tail -n 1)
set +e
test "$LATEST_TAG" != 'v${{ steps.version.outputs.result }}'
echo "latest=$?" >> $GITHUB_OUTPUT
- name: Tag latest
if: steps.latest-version.outputs.latest == '1'
run: |
export VERSION=$(echo ${{ steps.version.outputs.result }} | grep -Po '3\.\d+')
docker tag ${DOCKER_PREFIX}/lorawan-stack:${VERSION}-amd64 ${DOCKER_PREFIX}/lorawan-stack:latest-amd64
docker tag ${DOCKER_PREFIX}/lorawan-stack:${VERSION}-arm64 ${DOCKER_PREFIX}/lorawan-stack:latest-arm64
docker tag ${DOCKER_PREFIX}/lorawan-stack:${VERSION}-armv7 ${DOCKER_PREFIX}/lorawan-stack:latest-armv7
docker push ${DOCKER_PREFIX}/lorawan-stack:latest-amd64
docker push ${DOCKER_PREFIX}/lorawan-stack:latest-arm64
docker push ${DOCKER_PREFIX}/lorawan-stack:latest-armv7
docker manifest create ${DOCKER_PREFIX}/lorawan-stack:latest ${DOCKER_PREFIX}/lorawan-stack:latest-amd64 ${DOCKER_PREFIX}/lorawan-stack:latest-arm64 ${DOCKER_PREFIX}/lorawan-stack:latest-armv7
docker manifest push ${DOCKER_PREFIX}/lorawan-stack:latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_PREFIX: thethingsnetwork
- uses: bufbuild/buf-push-action@v1
with:
input: api
buf_token: ${{ secrets.BUF_TOKEN }}
- name: Prepare merge PR
run: |
gh pr create \
--assignee '${{ github.actor }}' \
--base "$(echo ${{ steps.version.outputs.result }} | grep -Po 'v3\.\d+')" \
--body "This pull request merges back changes from the v${{ steps.version.outputs.result }} release." \
--label "release" \
--milestone "v${{ steps.version.outputs.result }}" \
--title "Release v${{ steps.version.outputs.result }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}