-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (106 loc) · 4.21 KB
/
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
name: Release
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.release.outputs.published }}
release-git-tag: ${{ steps.release.outputs.release-git-tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release
id: release
uses: ahmadnassri/action-semantic-release@v2.2.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
artifacts:
needs: release
name: Create Release Artifacts
strategy:
matrix:
architecture: [aarch64, x86_64]
ostype: [linux-gnu, linux-musl]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Set environment variables
run: |
echo "ARCHITECTURE=${{ matrix.architecture }}" >> $GITHUB_ENV
echo "OSTYPE=${{ matrix.ostype }}" >> $GITHUB_ENV
echo "REGISTRY=ghcr.io"
- name: Build, and Package
run: make build/package
- name: Log in to the Container registry
if: ${{ needs.release.outputs.published == 'true' }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
if: ${{ needs.release.outputs.published == 'true' }}
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/kong/template-github-release
sep-tags: ' '
flavor: |
suffix=-${{ matrix.architecture }}-${{ matrix.ostype }}
tags: |
type=sha
type=ref,event=branch
type=semver,pattern={{version}},value=${{ needs.release.outputs.release-git-tag }}
type=semver,pattern={{major}},value=${{ needs.release.outputs.release-git-tag }}
- name: Retag and Push
if: ${{ needs.release.outputs.published == 'true' }}
run: |
for tag in ${{ steps.meta.outputs.tags }}; do \
docker tag ghcr.io/template-github-release:build-$ARCHITECTURE-$OSTYPE $tag && \
docker push $tag; \
done
- name: Archive the package
if: ${{ needs.release.outputs.published == 'true' }}
run: |
tar -C package -czvf ${{ matrix.architecture }}-${{ matrix.ostype }}.tar.gz .
- name: Add Release Artifact to the Github Release
if: ${{ needs.release.outputs.published == 'true' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.release.outputs.release-git-tag }}
files: ${{ matrix.architecture }}-${{ matrix.ostype }}.tar.gz
multi-arch:
needs: [release, artifacts]
name: Create Release Artifacts
if: ${{ needs.release.outputs.published == 'true' }}
strategy:
matrix:
ostype: [linux-gnu, linux-musl]
runs-on: ubuntu-latest
steps:
- name: Log in to the Container registry
if: ${{ needs.release.outputs.published == 'true' }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Combine per architecture images into a single multi-arch manifest
run: |
docker pull ghcr.io/kong/template-github-release:${{ needs.release.outputs.release-git-tag }}-aarch64-${{ matrix.ostype }}
docker pull ghcr.io/kong/template-github-release:${{ needs.release.outputs.release-git-tag }}-x86_64-${{ matrix.ostype }}
docker manifest create ghcr.io/kong/template-github-release:${{ needs.release.outputs.release-git-tag }}-${{ matrix.ostype }} \
ghcr.io/kong/template-github-release:${{ needs.release.outputs.release-git-tag }}-aarch64-${{ matrix.ostype }} \
ghcr.io/kong/template-github-release:${{ needs.release.outputs.release-git-tag }}-x86_64-${{ matrix.ostype }}
docker manifest push ghcr.io/kong/template-github-release:${{ needs.release.outputs.release-git-tag }}-${{ matrix.ostype }}