-
-
Notifications
You must be signed in to change notification settings - Fork 20
74 lines (62 loc) · 2.92 KB
/
build-and-bump.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
name: Build, minify, lower syntax, bump versions, update download counts & changelog
on:
push:
branches: [main]
paths:
- source/** # only trigger when source files were changed
- .github/workflows/build-and-bump.yml # or on updates to this file itself
workflow_dispatch: # allows manual triggering on GitHub
permissions:
contents: write
#───────────────────────────────────────────────────────────────────────────────
jobs:
bump:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v4
# By default, no tags and only a single commit is fetched. To use git
# history in the changelog step, we need to fetch all history.
with:
fetch-depth: 0 # 0 = all history
fetch-tags: true
- name: setup node
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: build, lower syntax, and minify
run: |
# Due to globbing, the source files are inserted in alphabetical order.
# To keep things predictable, they are simply number in the order they
# should be included in.
cat ./source/*.css > ./theme.css
# minification & syntax-lowering https://lightningcss.dev/transpilation.html
npm install
export BROWSERSLIST="chrome 108" # lowers syntax to before css-nesting
npx lightningcss --minify --browserslist \
--output-file="./theme.css" -- "./theme.css" || exit 1
# append style-settings (last, so not removed by minification)
cat <(echo && echo "/* @settings") ./source/style-settings.yaml <(echo "*/") \
>> ./theme.css
- name: bump version in manifest
run: |
version=$(grep --max-count=1 '"version"' "./manifest.json" | cut -d'"' -f4 | cut -d'.' -f2)
sed -i '' "/version/ s/\.$version/.$((version + 1))/" "./manifest.json"
- name: update download count in readme
run: |
dl=$(curl -s "https://releases.obsidian.md/stats/theme" |
grep -oe '"Shimmering Focus","download":[[:digit:]]*' |
cut -d: -f2)
sed -E -i '' "s/badge.*-[0-9]+-/badge\/downloads-$dl-/" ./README.md
- name: update changelog
run: |
git log :/bump.. --format="- %cs %s" | # commits since last `bump` commit
grep -vE "build|ci|refactor|style|bump" | # don't include internal changes
sed -E "s/^(- [0-9-]+) ([^ ]+): /\1 **\2**: /" >> "temp.md" # bold cc keyword
grep -v "^$" "Changelog.md" >> "temp.md"
mv -f "temp.md" "Changelog.md"
- name: commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "bump: version & update changelog"
branch: ${{ github.head_ref }}