chore: some cleanup of the style settings #86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and bump | |
on: | |
push: | |
branches: [main] | |
paths: | |
- source/** | |
- .github/workflows/build-and-bump.yml | |
workflow_dispatch: | |
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 https://caniuse.com/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: check for unsupported features | |
run: | | |
violations=$(npx doiuse --browsers="$BROWSERSLIST" \ | |
--config="./.doiuse-ignore.json" theme.css) | |
if [[ -n "$violations" ]]; then # `doiuse` does not exit with non-zero code | |
echo "Doiuse violations:" | |
echo "$violations" | |
exit 1 | |
fi | |
- 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||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 bump & changelog update" | |
branch: ${{ github.head_ref }} |