-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (74 loc) · 2.45 KB
/
create_release.yaml
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
on:
pull_request:
types:
- closed
env:
REGISTRY: ghcr.io
IMAGE_NAME: w6d-io/process-rest
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'release') }}
permissions:
id-token: write
contents: write
packages: write
attestations: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Build variables
id: build_env
run: |
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
echo "PROJECT_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" >> $GITHUB_ENV
echo "VCS_REF=$GITHUB_SHA" >> $GITHUB_ENV
- name: Generate tag
id: generate_tag
uses: K-Phoen/semver-release-action@master
with:
release_branch: main
release_strategy: none
env:
GITHUB_TOKEN: ${{ secrets.WF_TOKEN }}
- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: |
VERSION=${{ steps.generate_tag.outputs.tag }}
VCS_REF=${{ env.VCS_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}
PROJECT_URL=${{ env.PROJECT_URL }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.generate_tag.outputs.tag }}
- name: Push tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.WF_TOKEN }}
tags: true
push_only_tags: true