-
-
Notifications
You must be signed in to change notification settings - Fork 52
139 lines (121 loc) · 4.3 KB
/
release.yaml
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
name: Release Workflow
on:
workflow_dispatch:
inputs:
version:
description: "The version to release (e.g., 0.12.0)"
required: true
jobs:
# Job 1: Bump Versions and Create Tags
versioning:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
# 1. Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# 2. Setup node & npm
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
# 3. Bump versions using npm
- name: Bump version in web and docs
id: set_version
run: |
VERSION=${{ github.event.inputs.version }}
cd web && npm version $VERSION --no-git-tag-version && cd ..
cd docs && npm version $VERSION --no-git-tag-version && cd ..
echo "version=v$VERSION" >> $GITHUB_OUTPUT
# 4. Tag and push the new versions
- name: Commit and Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add web/package.json docs/package.json
git commit -m "Release ${{ github.event.inputs.version }}"
git tag "v${{ github.event.inputs.version }}"
git push origin main --tags
# Job 2: Build Docker Images
docker-build:
runs-on: ubuntu-latest
needs: versioning
steps:
# 1. Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
# 2. Log in to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 3. Setup docker multi platform builds
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 4. Build and push Docker images
- name: Build Docker Images
env:
VERSION: ${{ needs.versioning.outputs.version }}
run: |
# Build db image
cd db
env GOOS=linux GOARCH=arm64 go build -o pocketbase_arm64
env GOOS=linux GOARCH=amd64 go build -o pocketbase_amd64
cd ..
docker buildx build db/ --no-cache -t flomp/wanderer-db:$VERSION -t flomp/wanderer-db:latest --platform=linux/amd64,linux/arm64 --push
# Build web image
export PUBLIC_VALHALLA_URL=https://valhalla1.openstreetmap.de
cd web
npm ci && npm run build
cd ..
docker buildx build web/ --no-cache -t flomp/wanderer-web:$VERSION -t flomp/wanderer-web:latest --platform=linux/amd64,linux/arm64 --push
# Build docs image
cd docs
npm ci && npm run build
cd ..
docker buildx build docs/ --no-cache -t flomp/wanderer-docs:$VERSION -t flomp/wanderer-docs:latest --platform=linux/amd64,linux/arm64 --push
# Job 3: Publish the Release
release:
runs-on: ubuntu-latest
needs: [versioning, docker-build]
steps:
# 1. Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
# 2. Extract release notes from CHANGELOG.md
- name: Extract release notes
id: changelog
run: |
VERSION="${{ needs.versioning.outputs.version }}"
CHANGELOG=$(awk -v ver="$VERSION" '
BEGIN { in_section = 0 }
/^# / {
if (in_section) exit
if ($2 == ver) in_section = 1
}
in_section { print }
' CHANGELOG.md)
echo 'changelog<<EOF' >> $GITHUB_OUTPUT
printf "%s\n" "$CHANGELOG" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
# 3. Create GitHub Release
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ needs.versioning.outputs.version }}
release_name: "${{ needs.versioning.outputs.version }}"
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}