-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (41 loc) · 1.59 KB
/
Copy pathrelease.yml
File metadata and controls
47 lines (41 loc) · 1.59 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
name: Release
# Tag-driven: push a `vX.Y.Z` tag matching addon.xml's version to cut a
# release. Builds the exact bytes that ship (git archive honors
# .gitattributes export-ignore, so tests/, tools/ and this .github/ tree
# never reach the zip) and attaches the zip to a new GitHub Release. See
# .github/RELEASING.md for the full tag-to-release flow.
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build and publish release zip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify tag matches addon.xml version
run: |
ADDON_ID=$(sed -n 's/.*<addon id="\([^"]*\)".*/\1/p' addon.xml)
VERSION=$(sed -n 's/.*<addon [^>]*version="\([^"]*\)".*/\1/p' addon.xml | head -n1)
TAG="${GITHUB_REF#refs/tags/}"
echo "Addon id: $ADDON_ID, addon.xml version: $VERSION, tag: $TAG"
if [ "$TAG" != "v$VERSION" ]; then
echo "::error::Tag $TAG does not match addon.xml version $VERSION (expected v$VERSION)."
exit 1
fi
echo "ADDON_ID=$ADDON_ID" >> "$GITHUB_ENV"
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Build addon zip from git archive
run: |
mkdir -p dist
git archive --format=zip --prefix="$ADDON_ID/" -o "dist/$ADDON_ID-$VERSION.zip" HEAD
- name: Create release and attach zip
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" "dist/$ADDON_ID-$VERSION.zip" \
--title "$ADDON_ID $VERSION" \
--generate-notes