-
-
Notifications
You must be signed in to change notification settings - Fork 60
78 lines (66 loc) · 2.58 KB
/
ci-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
# Build new docker image when a new tag is pushed, and generate changelog and release notes and use the tag as the release name.
# if the tag has beta or alfa in the name, set the release as a pre-release.
name: Build release image
on:
push:
tags:
- "v*"
# trigger workflow manually
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. v0.0.2)"
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: Extract version number
id: extract_version
run: |
echo "raw_tag=${{ steps.previoustag.outputs.tag }}"
version_number="${{ steps.previoustag.outputs.tag }}"
if [[ ${version_number:0:1} == "v" ]]; then
version_number=${version_number:1}
fi
echo "version_number=$version_number"
echo "::set-output name=version_number::$version_number"
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
"NEXT_PUBLIC_APP_VERSION=${{ steps.previoustag.outputs.tag }}"
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ steps.extract_version.outputs.version_number }}
# - uses: "marvinpinto/action-automatic-releases@latest"
# with:
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
# prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alfa') }}
# files: |
# LICENSE
# README.md
# prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alfa') }}
# automatic_release_tag: ${{ github.event.inputs.version || steps.previoustag.outputs.tag }}
# title: ${{ steps.previoustag.outputs.tag }}