generated from siyuan-note/theme-sample
-
Notifications
You must be signed in to change notification settings - Fork 5
70 lines (58 loc) · 2.22 KB
/
main.yml
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
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Extract latest changelog entry
id: changelog
run: |
CHANGELOG_FILE="CHANGELOG.md"
if [ ! -f "$CHANGELOG_FILE" ]; then
echo "Error: $CHANGELOG_FILE does not exist."
exit 1
fi
CHANGELOG_CONTENT=$(awk '/^## / {print; getline; while ($0 !~ /^### / && $0 != "") {print; getline}}' "$CHANGELOG_FILE")
if [ -z "$CHANGELOG_CONTENT" ]; then
echo "Error: Could not extract the latest changelog entry."
echo "::error::Extracted content is empty."
exit 1
fi
echo "Extracted changelog content:"
echo "$CHANGELOG_CONTENT"
echo "::set-output name=content::$CHANGELOG_CONTENT"
- name: Create or update annotated tag with changelog
run: |
TAG_NAME="${{ github.ref_name }}"
CHANGELOG_CONTENT="${{ steps.changelog.outputs.content }}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists. Updating tag message."
git tag -d "$TAG_NAME"
git push origin :"$TAG_NAME"
fi
git tag -a "$TAG_NAME" -m "$CHANGELOG_CONTENT"
git push origin "$TAG_NAME"
- name: Zip Release
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
filename: 'package.zip'
exclusions: '*.git* *.scss /*style/* /*assets/* /*js/*'
- name: Create Release
uses: ncipollo/release-action@v1.13.0
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "package.zip"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.content }}