-
Notifications
You must be signed in to change notification settings - Fork 134
76 lines (73 loc) · 2.55 KB
/
release-build.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
name: Release Build
on:
push:
branches:
- master
tags:
- v*
jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create release
id: create_release
if: github.ref_name != 'master'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: ${{ contains(github.ref_name, 'beta') }}
build:
needs: create_release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version
if: github.ref_name != 'master'
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set Docker Tag
run: |
echo "DOCKER_TAG=blackcandy/blackcandy:latest,blackcandy/blackcandy:${{ env.VERSION }},ghcr.io/blackcandy-org/blackcandy:latest,ghcr.io/blackcandy-org/blackcandy:${{ env.VERSION }}" >> $GITHUB_ENV
- name: Remove Latest Docker Tag
if: contains(github.ref_name, 'beta')
run: |
echo "DOCKER_TAG=blackcandy/blackcandy:${{ env.VERSION }},ghcr.io/blackcandy-org/blackcandy:${{ env.VERSION }}" >> $GITHUB_ENV
- name: Set Edge Docker Tag
if: github.ref_name == 'master'
run: |
touch .is-edge-release.txt
echo "DOCKER_TAG=blackcandy/blackcandy:edge,ghcr.io/blackcandy-org/blackcandy:edge" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAG }}