Repository navigation
121 lines (108 loc) · 3.82 KB
/
Copy pathrelease.yml
File metadata and controls
121 lines (108 loc) · 3.82 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
119
120
121
---
name: Release
permissions: {}
"on":
push:
tags:
- "v*.*.*"
concurrency: release-${{ github.ref }}
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tag: ${{ steps.meta.outputs.tag }}
prerelease: ${{ steps.meta.outputs.prerelease }}
latest: ${{ steps.meta.outputs.latest }}
prev: ${{ steps.meta.outputs.prev }}
apps: ${{ steps.meta.outputs.apps }}
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Compute release metadata
id: meta
env:
TAG: ${{ github.ref_name }}
run: |
if ! echo "$TAG" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
echo "::error::Invalid tag format: $TAG"
echo "::error::Tag must be in semver format: v<MAJOR>.<MINOR>.<PATCH>[-PRERELEASE] (no +BUILD)"
exit 1
fi
prerelease=false
[[ "$TAG" == *-* ]] && prerelease=true
highest=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n1)
latest=false
[ "$TAG" = "$highest" ] && latest=true
exclude=()
[ "$prerelease" = false ] && exclude=(--exclude='v*-*')
prev=$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' "${exclude[@]}" "$TAG^" 2>/dev/null) \
|| prev=$(git rev-list --max-parents=0 HEAD | tail -n1)
apps=$(for f in apps/*/Dockerfile; do
jq -c -n --arg name "ev-node-$(basename "$(dirname "$f")")" --arg dockerfile "$f" '{name: $name, dockerfile: $dockerfile}'
done | jq -c -s .)
{
echo "tag=$TAG"
echo "prerelease=$prerelease"
echo "latest=$latest"
echo "prev=$prev"
echo "apps=$apps"
} >> "$GITHUB_OUTPUT"
echo "::notice::tag=$TAG prerelease=$prerelease latest=$latest prev=$prev apps=$apps"
docker:
name: Docker images
needs: prepare
permissions:
contents: read
packages: write
uses: ./.github/workflows/docker-build-push.yml
with:
image-tag: ${{ needs.prepare.outputs.tag }}
apps: ${{ needs.prepare.outputs.apps }}
latest: ${{ needs.prepare.outputs.latest == 'true' }}
release:
name: GitHub Release
needs: [prepare, docker]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Generate release notes
uses: orhun/git-cliff-action@v4
with:
version: v2.14.2
config: cliff.toml
args: --strip header --tag ${{ needs.prepare.outputs.tag }} ${{ needs.prepare.outputs.prev }}..${{ needs.prepare.outputs.tag }}
env:
OUTPUT: NOTES.md
- name: Append images and diff link
env:
TAG: ${{ needs.prepare.outputs.tag }}
PREV: ${{ needs.prepare.outputs.prev }}
APPS: ${{ needs.prepare.outputs.apps }}
REGISTRY: ghcr.io/${{ github.repository_owner }}
REPO: ${{ github.repository }}
run: |
{
echo
echo "## Docker images"
echo
jq -r --arg reg "$REGISTRY" --arg tag "$TAG" '.[] | "- `\($reg)/\(.name):\($tag)`"' <<<"$APPS"
echo
echo "**Full diff:** https://github.com/$REPO/compare/$PREV...$TAG"
} >> NOTES.md
- name: Publish release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: ev-node ${{ needs.prepare.outputs.tag }}
body_path: NOTES.md
draft: false
prerelease: ${{ needs.prepare.outputs.prerelease }}
make_latest: ${{ needs.prepare.outputs.latest }}