forked from DragosOnisei/FrameComment
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (104 loc) · 3.8 KB
/
Copy pathrelease.yml
File metadata and controls
118 lines (104 loc) · 3.8 KB
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
112
113
114
115
116
117
118
name: Release
# Triggered by pushing a SemVer tag (e.g. `v1.0.0`, `v1.2.3`).
# - Builds a multi-arch (amd64, arm64) Docker image.
# - Pushes to Docker Hub as `dragosonisei/framecomment:<version>` and `:latest`.
# - Creates a GitHub Release with the relevant CHANGELOG section.
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write # needed to create the GitHub Release
env:
IMAGE_NAME: dragosonisei/framecomment
jobs:
build-and-release:
name: Build & publish ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify tag matches package.json
id: verify
run: |
set -euo pipefail
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(node -p "require('./package.json').version")
FILE_VERSION=$(cat VERSION)
echo "tag=$TAG_VERSION"
echo "package.json=$PKG_VERSION"
echo "VERSION file=$FILE_VERSION"
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag $TAG_VERSION does not match package.json version $PKG_VERSION"
exit 1
fi
if [ "$TAG_VERSION" != "$FILE_VERSION" ]; then
echo "::error::Tag $TAG_VERSION does not match VERSION file $FILE_VERSION"
exit 1
fi
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
- name: Extract changelog section
id: changelog
run: |
set -euo pipefail
VERSION="${{ steps.verify.outputs.version }}"
# Pull the section between "## [VERSION]" and the next "## [" header.
awk -v ver="$VERSION" '
$0 ~ "^## \\[" ver "\\]" {flag=1; next}
flag && $0 ~ "^## \\[" {flag=0}
flag {print}
' CHANGELOG.md > release-notes.md
echo "----- release-notes.md -----"
cat release-notes.md
echo "----------------------------"
- 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.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Compute Docker tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
# NOTE: linux/arm64 was removed in v1.0.1 because QEMU on the
# GitHub-hosted x86 runners crashes during Next.js webpack compile
# ("Illegal instruction"). v1.0.2 will reintroduce arm64 using
# GitHub's free native ARM runners with a matrix strategy.
- name: Build & push image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
APP_VERSION=${{ steps.verify.outputs.version }}
provenance: true
sbom: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: release-notes.md
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
generate_release_notes: false
files: |
docker-compose.yml
docker-compose.truenas.yml
docker-compose.unraid.yml
.env.example