forked from AdguardTeam/AdGuardHome
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (154 loc) · 6.65 KB
/
build-and-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
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
165
166
167
168
name: 'Build and release'
on:
push:
tags:
- 'v*'
branches:
- master
env:
GO_VERSION: '1.23.3'
NODE_VERSION: '18.20.4'
DIST_FOLDER: 'dist'
REGISTRY: 'ghcr.io'
SSH_KEY_FILE_DIR: .keys
SSH_KEY_FILE_PATH: .keys/deploy_key.pem
DEV_VERSION_NAME: 'v0.0.0-d.0'
DEV_VERSION_CHECK: 'd.'
BUILD_CHANNEL: 'release'
concurrency:
group: build_${{ github.event.head_commit.id }}
cancel-in-progress: true
jobs:
build_and_release:
runs-on: 'ubuntu-latest'
env:
GO111MODULE': 'on'
GOPROXY: 'https://goproxy.cn'
VERSION: ${{ github.ref_name == 'master' && 'v0.0.0-d.0' || github.ref_name }}
NPM_CACHE_DIR: ''
PREV_VERSION: 'master'
CHANGE_LOGS: '* ${{ github.event.head_commit.message }}'
steps:
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5.0.0
with:
'go-version': '${{ env.GO_VERSION }}'
- name: Set up Node
uses: actions/setup-node@v4
with:
'node-version': '${{ env.NODE_VERSION }}'
- name: 'Get npm cache directory'
id: 'npm-cache'
run: echo "NPM_CACHE_DIR=$(npm config get cache)" >> $GITHUB_ENV
- name: 'Set up npm cache'
if: ${{env.NPM_CACHE_DIR != ''}}
uses: actions/cache@v4
with:
path: '${{ env.NPM_CACHE_DIR }}'
key: "${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}"
restore-keys: '${{ runner.os }}-node-'
- name: Set previous version env
if: ${{ env.VERSION != env.DEV_VERSION_NAME }}
run: |
PREV_VERSION=$(git describe --tags --abbrev=0 ${{env.VERSION}}^)
if [[ "$PREV_VERSION" == "v"* ]]
then
echo "PREV_VERSION=${PREV_VERSION}" >> $GITHUB_ENV
else
echo "Can not find prev version. Use ${{env.PREV_VERSION}} as prev version"
fi
- name: Set change logs env
if: ${{ env.VERSION != env.DEV_VERSION_NAME }}
run: |
CHANGE_LOGS=$(git log --no-merges --pretty='format:* %h: %s' ${{env.VERSION}}...${{env.PREV_VERSION}})
if [ "$CHANGE_LOGS" != "" ]
then
{
echo 'CHANGE_LOGS<<EOF'
echo "$CHANGE_LOGS"
echo EOF
} >> $GITHUB_ENV
else
echo "Get change log error. Use lastest commit message as change log"
fi
# Release build block
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set beta build channel
if: ${{ contains(env.VERSION, 'b.') }}
run: echo "BUILD_CHANNEL=beta" >> $GITHUB_ENV
- name: Run release build
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
run: |
make SIGN=0 VERBOSE=1 CHANNEL="${{env.BUILD_CHANNEL}}" DOCKER_IMAGE_NAME="${{env.REGISTRY}}/abpvn/adguardhome" \
DOCKER_OUTPUT="type=image,name=${{env.REGISTRY}}/abpvn/adguardhome,push=true" VERSION="${{env.VERSION}}" \
build-release build-docker
rm -rf ${{env.DIST_FOLDER}}/AdGuardHome_frontend.tar.gz
- name: Create release
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
uses: ncipollo/release-action@v1
with:
prerelease: ${{ env.BUILD_CHANNEL != 'release' }}
artifacts: "${{ env.DIST_FOLDER }}/*.tar.gz,${{ env.DIST_FOLDER }}/*.zip,${{ env.DIST_FOLDER }}/checksums.txt"
body: |
## ${{env.BUILD_CHANNEL == 'release' && 'Stable' || 'Beta'}} release for per client filter configuration
### Build information:
* GO version: **${{ env.GO_VERSION }}**
* Node version: **${{ env.NODE_VERSION }}**
* Release version: **${{ env.VERSION }}**
### What's changed:
${{ env.CHANGE_LOGS }}
**Full Changelog**: https://github.com/abpvn/AdGuardHome/compare/${{env.PREV_VERSION}}...${{env.VERSION}}
**Notice**: This is just a custom implement by ABPVN. It's may contain bug and performance issue. Use at your own risk
- name: Create deploy key file
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
run: |
mkdir ${{env.SSH_KEY_FILE_DIR}}
echo "${{secrets.SSH_DEPLOY_KEY}}" > ${{env.SSH_KEY_FILE_PATH}}
chmod 600 ${{env.SSH_KEY_FILE_PATH}}
- name: Copy version file to Server
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
run: |
rsync -have "ssh -i ${{env.SSH_KEY_FILE_PATH}} -o StrictHostKeyChecking=no" ${{ env.DIST_FOLDER }}/version.json ${{secrets.SSH_DEPLOY_USER}}@${{secrets.SSH_MAIN_HOST}}:${{secrets.DEPLOY_PATH}}/${{env.BUILD_CHANNEL}}/
- name: Clean deploy key file
if: ${{ !contains(env.VERSION, env.DEV_VERSION_CHECK) }}
run: rm -rf ${{env.SSH_KEY_FILE_PATH}}
# Development build block
- name: Run development build
if: ${{ contains(env.VERSION, env.DEV_VERSION_CHECK) }}
run: |
make SIGN=0 VERBOSE=1 VERSION="${{env.VERSION}}" build-release
rm -rf ${{env.DIST_FOLDER}}/AdGuardHome_frontend.tar.gz
- name: Create development release
if: ${{ env.VERSION != env.DEV_VERSION_NAME && contains(env.VERSION, env.DEV_VERSION_CHECK) }}
uses: ncipollo/release-action@v1
with:
prerelease: true
artifacts: "${{ env.DIST_FOLDER }}/*.tar.gz,${{ env.DIST_FOLDER }}/*.zip,${{ env.DIST_FOLDER }}/checksums.txt"
body: |
## Development release for per client filter configuration
### Build information:
* GO version: **${{ env.GO_VERSION }}**
* Node version: **${{ env.NODE_VERSION }}**
* Release version: **${{ env.VERSION }}**
### What's changed:
${{ env.CHANGE_LOGS }}
**Full Changelog**: https://github.com/abpvn/AdGuardHome/compare/${{env.PREV_VERSION}}...${{env.VERSION}}
**Notice**: This is just a development version with a few test. It's may contain a lot of bug and performance issue. Use at your own risk