Skip to content

Commit

Permalink
build: bump & update changelog via GitHub action instead of locally
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Jun 11, 2024
1 parent ddf0f45 commit e5e10ba
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 59 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build-and-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build, Bump version numbers, and update changelog

on:
push:
branches: [main] # not on insider release branch
workflow_dispatch:

permissions:
contents: write

jobs:
bump:
runs-on: macos-latest
name: Build, Bump version numbers, and update changelog
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 steop, we need to fetch all history.
with:
fetch-depth: 0 # 0 = all history
fetch-tags: true

#─────────────────────────────────────────────────────────────────────────

- name: Build
run: |
cat ./source/*.css <(echo "/* @settings") ./source/style-settings.yaml <(echo "*/") \
> ./theme.css
- name: Bump version numbers
run: |
theme_header="./source/00 header.css"
versionLine=$(grep --line-number --max-count=1 "^Version" "$theme_header")
versionLnum=$(echo "$versionLine" | cut -d: -f1)
currentVer=$(echo "$versionLine" | cut -d. -f2)
nextVer=$((currentVer + 1))
sed -E -i '' "${versionLnum} s/$currentVer/$nextVer/" "$theme_header"
sed -E -i '' "${versionLnum} s/$currentVer/$nextVer/" "./theme.css"
sed -E -i '' "/version/ s/$currentVer/$nextVer/" "./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.*-[[:digit:]]+-/badge\/downloads-$dl-/" ./README.md
- name: Update Changelog
run: |
commits_since_last_publish=$(git log :/bump.. --format="- %cs %s")
echo "$commits_since_last_publish" |
grep -vE "build|ci|style|bump" | # don't include internal changes
sed -E "s/^(- [0-9-]+) ([^ ]+): /\1 **\2**: /" >> "temp.md" # bold title
grep -v "^$" "Changelog.md" >> "temp.md"
mv -f "temp.md" "Changelog.md"
#─────────────────────────────────────────────────────────────────────────

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "bump: version & update changelog"
branch: ${{ github.head_ref }}
27 changes: 10 additions & 17 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
set quiet := true

vault_to_open := "main-vault"

#───────────────────────────────────────────────────────────────────────────────

_build:
# uses personal vaults saved in `~/.config/perma-repos.csv`
build_and_push_to_local_vaults:
#!/usr/bin/env zsh
# BUILD
# 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 <(echo "/* @settings") ./source/style-settings.yaml <(echo "*/") \
> ./theme.css
> /tmp/theme.css
# uses personal vaults saved in `~/.config/perma-repos.csv`
_push-to-local-vaults:
#!/usr/bin/env zsh
# PUSH TO LOCAL VAULTS
cut -d, -f2 "$HOME/.config/perma-repos.csv" |
sed "s|^~|$HOME|" |
xargs -I {} find {} -maxdepth 1 -name ".obsidian" | # only vaults
xargs dirname | # vault root
xargs -I {} cp -f "./theme.css" "{}/.obsidian/themes/Shimmering Focus/theme.css"
#──────────────────────────────────────────────────────────────────────────────

build-and-reload: && _build _push-to-local-vaults
open -a "Obsidian"

theme_header := "./source/00 header.css"

bump-version-and-changelog: && _build _push-to-local-vaults
zsh ./bump-version-and-changelog.sh "{{ theme_header }}"
xargs -I {} cp -f "/tmp/theme.css" "{}/.obsidian/themes/Shimmering Focus/theme.css"

only-build: _build
# OPEN OBSIDIAN
open "obsidian://open?vault={{ vault_to_open }}"
42 changes: 0 additions & 42 deletions bump-version-and-changelog.sh

This file was deleted.

0 comments on commit e5e10ba

Please sign in to comment.