From b05ef16265b0b6a3c67b9f35d4948a57b04a301d Mon Sep 17 00:00:00 2001 From: Matt B Date: Sun, 25 Oct 2026 13:36:23 +1000 Subject: [PATCH] Add publish workflow --- .gitea/workflows/publish.yml | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitea/workflows/publish.yml diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..202a20d --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,41 @@ +name: Publish userscripts +on: + push: + branches: [main] + paths: + - 'src/**' + - '.gitea/workflows/**' + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build dist + run: | + VERSION=$(TZ=AEST-10 date +%Y.%m.%d.%H%M) + BASE=https://code.home-brightview.com/matt.rb/dynamics-userscripts/raw/branch/dist + mkdir -p dist + for f in src/*.user.js; do + n=$(basename "$f" .user.js) + sed -e "s|^// @version .*|// @version $VERSION|" \ + -e "s|^// ==/UserScript==|// @updateURL $BASE/$n.meta.js\n// @downloadURL $BASE/$n.user.js\n// ==/UserScript==|" \ + "$f" > "dist/$n.user.js" + sed -n '1,/==\/UserScript==/p' "dist/$n.user.js" > "dist/$n.meta.js" + echo "Built $n $VERSION" + done + echo "VERSION=$VERSION" >> "$GITHUB_ENV" + + - name: Force-push dist branch + env: + TOKEN: ${{ secrets.PUBLISH_TOKEN }} + run: | + cd dist + git init -b dist + git config user.name "gitea-actions" + git config user.email "actions@home-brightview.com" + git add . + git commit -m "Publish $VERSION" + git push -f "https://matt.rb:${TOKEN}@git.home-brightview.com/${{ github.repository }}.git" dist \ No newline at end of file