-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (70 loc) · 2.19 KB
/
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
name: release
on:
workflow_run:
workflows: [ci]
branches: [main]
types: [completed]
concurrency:
group: release
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
new_tag: ${{ steps.version.outputs.new_tag }}
changelog: ${{ steps.version.outputs.changelog }}
date: ${{ steps.build_meta.outputs.date }}
steps:
- name: Bump release version and push tag
id: version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: false
- name: Prepare build metadata
id: build_meta
run: |
echo "::set-output name=date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
publish:
runs-on: ubuntu-latest
needs: prepare
if: needs.prepare.outputs.new_tag != ''
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare tags for docker image
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/sergeii/swat4master
tags: |
type=raw,prefix=,value=${{ needs.prepare.outputs.new_tag }}
flavor: |
latest=true
prefix=
suffix=
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
build_commit_sha=${{ github.sha }}
build_version=${{ needs.prepare.outputs.new_tag }}
build_time=${{ needs.prepare.outputs.date }}
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.prepare.outputs.new_tag }}
name: Release ${{ needs.prepare.outputs.new_tag }}
body: ${{ needs.prepare.outputs.changelog }}