Repository navigation
101 lines (89 loc) · 3.13 KB
/
Copy pathrelease.yml
File metadata and controls
101 lines (89 loc) · 3.13 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release, e.g. v1.0.19 (must already exist; run the workflow from that tag)"
required: true
permissions:
contents: write
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
changelog: ${{ steps.notes.outputs.changelog }}
build-per-platform: true
steps:
- name: Determine tag and version
id: tag
run: |
tag="${{ github.event.inputs.tag }}"
if [ -z "$tag" ]; then
tag="${GITHUB_REF_NAME}"
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
ref: ${{ steps.tag.outputs.tag }}
# publish-plugin.yml builds github.sha, not the tag input
- name: Verify the run is for the tagged commit
run: |
tagCommit=$(git rev-parse HEAD)
if [ "$tagCommit" != "$GITHUB_SHA" ]; then
echo "::error::Tag ${{ steps.tag.outputs.tag }} points at $tagCommit, but this run is for $GITHUB_SHA. Run the workflow from the tag."
exit 1
fi
- name: Verify manifest.json version matches the tag
run: |
manifestVersion=$(jq -r .version src/PrinterControl/manifest.json)
if [ "$manifestVersion" != "${{ steps.tag.outputs.version }}" ]; then
echo "::error::manifest.json version ($manifestVersion) does not match tag ${{ steps.tag.outputs.tag }}. Bump manifest.json's version, commit that, then tag the new commit."
exit 1
fi
- name: Generate release notes
id: notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
{
echo "changelog<<EOF_CHANGELOG_$GITHUB_RUN_ID"
gh api "repos/$GITHUB_REPOSITORY/releases/generate-notes" -f tag_name="${{ steps.tag.outputs.tag }}" -q .body
echo "EOF_CHANGELOG_$GITHUB_RUN_ID"
} >> "$GITHUB_OUTPUT"
publish:
needs: prepare
uses: Macro-Deck-App/GitHub-Actions/.github/workflows/publish-plugin.yml@v1
permissions:
contents: read
id-token: write
with:
version: ${{ needs.prepare.outputs.tag }}
source: src/PrinterControl
cli-version: 3.0.0-beta.15
changelog: ${{ needs.prepare.outputs.changelog }}
build-per-platform: true
upload-artifact: true
artifact-name: plugin-package
release:
needs: [prepare, publish]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: plugin-package
path: artifacts
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
CHANGELOG: ${{ needs.prepare.outputs.changelog }}
run: |
printf '%s\n' "$CHANGELOG" > notes.md
gh release create "${{ needs.prepare.outputs.tag }}" artifacts/*.macroDeckPlugin \
--title "${{ needs.prepare.outputs.tag }}" \
--notes-file notes.md