Merge branch 'AdguardTeam:master' into master #173
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Build and release' | |
on: | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- master | |
env: | |
GO_VERSION: '1.23.4' | |
NODE_VERSION: '18.20.5' | |
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 |