forked from lmg-anon/mikupad
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (67 loc) · 2.45 KB
/
compile_mikupad.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
71
72
73
74
75
76
77
78
79
80
name: Release Mikupad
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: run compile.sh
run: chmod +x compile.sh; ./compile.sh
- name: Determine Tag and Build Names
id: build_ids
run: |
# use number of commits as build ID
BUILD_NUMBER="$(git rev-list --count HEAD)"
echo "number=${BUILD_NUMBER}" >> $GITHUB_OUTPUT
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
echo "buildName=Mikupad #${BUILD_NUMBER} [${SHORT_HASH}]" >> $GITHUB_OUTPUT
echo "Build: $BUILD_NUMBER $SHORT_HASH"
- name: Get Last Release Tag
id: last_release
run: |
# find previous release to determine how many commits should be displayed in the changelog
TAG=$(git tag --list 'release*' --sort=-v:refname | head -n 1)
if [ -z "$TAG" ]; then
echo "No release tag found"
echo "tag=$(echo 'none')" >> $GITHUB_OUTPUT
else
TAG_NUMBER=$(echo $TAG | sed 's/release//')
echo "Found release tag: $TAG"
echo "tag=$TAG_NUMBER" >> $GITHUB_OUTPUT
fi
- name: Generate Changelog
id: changelog
run: |
# if no previous release, don't dump the entire history
if [ "${{ steps.last_release.outputs.tag }}" = "none" ]; then
echo "mikudayo~" > CHANGELOG.txt
else
OLD_COMMIT="${{ steps.last_release.outputs.tag }}"
NUM_COMMITS="${{ steps.build_ids.outputs.number }}"
NEW_COMMITS="$(($NUM_COMMITS - $OLD_COMMIT))"
echo "Generating changelog with $NEW_COMMITS commits starting from $OLD_COMMIT"
# echo changelog
echo "Generated $(date +'%Y-%m-%d %T')" >> CHANGELOG.txt
echo "\`\`\`" >> CHANGELOG.txt
echo "$(git log --graph -n $NEW_COMMITS --oneline)" >> CHANGELOG.txt
echo "\`\`\`" >> CHANGELOG.txt
fi
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: release${{ steps.build_ids.outputs.number }}
name: ${{ steps.build_ids.outputs.buildName }}
body_path: CHANGELOG.txt
files: mikupad_compiled.html
token: ${{ secrets.GITHUB_TOKEN }}