Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ‘· Streamlined auto-tagging

Alicia Sykes0cabd9be8f18
diff --git a/.github/workflows/manual-tag.yml b/.github/workflows/manual-tag.yml
deleted file mode 100644
index 85cf5ff0..00000000
--- a/.github/workflows/manual-tag.yml
+++ /dev/null
@@ -1,66 +0,0 @@
-# Manual fallback for creating a tag with optional version bump.
-# The automated flow is handled by bump-and-tag.yml on PR merge.
-name: 🏷️ Tag on Version Change
-
-on:
- workflow_dispatch:
- inputs:
- version:
- description: 'Version to tag (e.g. 3.2.0). Leave empty to auto-bump patch.'
- required: false
-
-concurrency:
- group: manual-tag-version
- cancel-in-progress: false
-
-jobs:
- tag-version:
- runs-on: ubuntu-latest
-
- steps:
- - name: Check Out Repository πŸ›ŽοΈ
- uses: actions/checkout@v6
- with:
- token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
- fetch-depth: 0
-
- - name: Configure Git Identity πŸ€–
- run: |
- git config user.name "Liss-Bot"
- git config user.email "[email protected]"
-
- - name: Determine and Apply Version πŸ”’
- id: version
- env:
- INPUT_VERSION: ${{ github.event.inputs.version }}
- run: |
- CURRENT=$(node -p "require('./package.json').version")
- if [ -n "$INPUT_VERSION" ]; then
- TARGET="${INPUT_VERSION#v}"
- else
- npm version patch --no-git-tag-version > /dev/null
- TARGET=$(node -p "require('./package.json').version")
- fi
- if [ "$TARGET" != "$CURRENT" ]; then
- npm version "$TARGET" --no-git-tag-version --allow-same-version
- git add package.json
- git commit -m "πŸ”– Bump version to $TARGET [skip ci]"
- git push
- echo "Committed version bump to $TARGET"
- else
- echo "package.json already at $CURRENT, skipping commit"
- fi
- echo "TARGET=$TARGET" >> $GITHUB_OUTPUT
-
- - name: Create and Push Tag ‴️
- env:
- TAG: ${{ steps.version.outputs.TARGET }}
- run: |
- git fetch --tags --force
- if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
- echo "Tag $TAG already exists, skipping"
- else
- git tag -a "$TAG" -m "Release v$TAG"
- git push origin "$TAG"
- echo "Created and pushed tag $TAG"
- fi
diff --git a/.github/workflows/bump-and-tag.yml b/.github/workflows/tag.yml
similarity index 67%
rename from .github/workflows/bump-and-tag.yml
rename to .github/workflows/tag.yml
index 4378d6aa..377b63fb 100644
--- a/.github/workflows/bump-and-tag.yml
+++ b/.github/workflows/tag.yml
@@ -1,17 +1,29 @@
-# Creates a new git tag when a PR is merged
+# Creates a new git tag when a PR is merged, or on manual dispatch
#
-# Here's the flow:
+# PR trigger flow:
# - Triggered whenever a PR is merged, if that PR made code changes
# - If version wasn't bumped in PR, increment patch version and update package.json
# - Otherwise (if the PR did bump version) we use the new version from package.json
# - Creates and pushes a git tag for the new version
# - That git tag then triggers Docker publishing and release drafting in other CI
-# - Add tags to issues from newly relesaed features/fixes (if applicable)
+# - Add labels and release comments to referenced issues (if applicable)
# - Trigger fresh deploy of docs site, so changelog remains up-to-date
# - Finally, shows summary of actions taken and new tag published
+#
+# Manual dispatch flow:
+# - If a version is provided, sets package.json to that version
+# - If no version is provided, increments patch version automatically
+# - Creates and pushes a git tag, then triggers docs site rebuild
+
name: πŸ”– Auto Version & Tag
on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Version to tag (e.g. 4.1.0). Leave blank to auto-increment patch.'
+ required: false
+ type: string
pull_request_target:
types: [closed]
branches: [master]
@@ -25,14 +37,37 @@ permissions:
pull-requests: read
issues: write
+env:
+ IS_MANUAL: ${{ github.event_name == 'workflow_dispatch' }}
+
jobs:
version-and-tag:
- if: github.event.pull_request.merged == true
+ if: >-
+ github.event_name == 'workflow_dispatch'
+ || github.event.pull_request.merged == true
runs-on: ubuntu-latest
+ timeout-minutes: 15
steps:
- - name: Check PR for code changes and version bump πŸ“‚
+ - name: πŸ”’ Validate manual dispatch
+ if: env.IS_MANUAL == 'true'
+ env:
+ INPUT_VERSION: ${{ inputs.version }}
+ DISPATCH_REF: ${{ github.ref }}
+ run: |
+ set -euo pipefail
+ if [ "$DISPATCH_REF" != "refs/heads/master" ]; then
+ echo "::error::Manual dispatch only allowed from master (got: $DISPATCH_REF)"
+ exit 1
+ fi
+ if [ -n "$INPUT_VERSION" ] && ! printf '%s' "$INPUT_VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
+ echo "::error::Invalid version '${INPUT_VERSION}'. Must be semver (e.g. 4.1.0)."
+ exit 1
+ fi
+
+ - name: πŸ“‚ Check PR for code changes and version bump
id: check_pr
+ if: env.IS_MANUAL != 'true'
uses: actions/github-script@v8
with:
script: |
@@ -43,7 +78,7 @@ jobs:
github.rest.pulls.listFiles, { owner, repo, pull_number }
);
const codePatterns = [
- /^src\//, /^services\//, /^public\//, /^Dockerfile$/, /^[^/]+\.js$/,
+ /^src\//, /^services\//, /^public\//, /^Dockerfile$/, /^yarn.lock$/, /^[^/]+\.js$/,
];
const codeChanged = files.some(f =>
codePatterns.some(p => p.test(f.filename))
@@ -83,21 +118,21 @@ jobs:
core.setOutput('needs_bump', needsBump.toString());
core.setOutput('needs_tag', needsTag.toString());
- - name: Checkout repository πŸ›ŽοΈ
- if: steps.check_pr.outputs.needs_tag == 'true'
+ - name: πŸ›ŽοΈ Checkout repository
+ if: env.IS_MANUAL == 'true' || steps.check_pr.outputs.needs_tag == 'true'
uses: actions/checkout@v6
with:
token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
- - name: Configure git identity πŸ‘€
- if: steps.check_pr.outputs.needs_tag == 'true'
+ - name: πŸ‘€ Configure git identity
+ if: env.IS_MANUAL == 'true' || steps.check_pr.outputs.needs_tag == 'true'
run: |
git config user.name "Liss-Bot"
git config user.email "[email protected]"
- - name: Extract referenced issues πŸ”
+ - name: πŸ” Extract referenced issues
id: issues
- if: steps.check_pr.outputs.needs_tag == 'true'
+ if: env.IS_MANUAL != 'true' && steps.check_pr.outputs.needs_tag == 'true'
uses: actions/github-script@v8
with:
script: |
@@ -119,47 +154,76 @@ jobs:
core.info(`Found issue references: ${unique.join(', ')}`);
core.setOutput('numbers', unique.join(','));
- - name: Bump patch version ⬆️
- if: steps.check_pr.outputs.needs_bump == 'true'
+ - name: ⬆️ Bump version
+ id: bump
+ if: >-
+ env.IS_MANUAL == 'true'
+ || steps.check_pr.outputs.needs_bump == 'true'
+ env:
+ INPUT_VERSION: ${{ inputs.version }}
run: |
- npm version patch --no-git-tag-version
+ set -euo pipefail
+ if [ "$IS_MANUAL" = "true" ] && [ -n "$INPUT_VERSION" ]; then
+ npm version "$INPUT_VERSION" --no-git-tag-version --allow-same-version
+ else
+ npm version patch --no-git-tag-version
+ fi
+ NEW_VERSION=$(node -p "require('./package.json').version")
git add package.json
- git commit -m "πŸ”– Bump version to $(node -p "require('./package.json').version")"
- git push
+ if git diff --cached --quiet; then
+ echo "package.json already at $NEW_VERSION, nothing to commit"
+ echo "bumped=false" >> "$GITHUB_OUTPUT"
+ else
+ git commit -m "πŸ”– Bump version to $NEW_VERSION"
+ git push
+ echo "bumped=true" >> "$GITHUB_OUTPUT"
+ fi
- - name: Create and push tag 🏷️
+ - name: 🏷️ Create and push tag
id: tag
- if: steps.check_pr.outputs.needs_tag == 'true'
+ if: env.IS_MANUAL == 'true' || steps.check_pr.outputs.needs_tag == 'true'
env:
- PR_NUMBER: ${{ github.event.pull_request.number }}
- PR_TITLE: ${{ github.event.pull_request.title }}
- PR_AUTHOR: ${{ github.event.pull_request.user.login }}
- MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
+ PR_NUMBER: ${{ github.event.pull_request.number || '' }}
+ PR_TITLE: ${{ github.event.pull_request.title || '' }}
+ PR_AUTHOR: ${{ github.event.pull_request.user.login || github.actor }}
+ MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
ISSUES: ${{ steps.issues.outputs.numbers }}
run: |
+ set -euo pipefail
VERSION=$(node -p "require('./package.json').version")
git fetch --tags --force
if git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists, skipping"
+ echo "result=existed" >> "$GITHUB_OUTPUT"
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
exit 0
fi
{
printf 'Dashy v%s πŸš€\n\n' "$VERSION"
- printf 'PR: #%s - %s\n' "$PR_NUMBER" "$PR_TITLE"
+ if [ -n "$PR_NUMBER" ]; then
+ printf 'PR: #%s - %s\n' "$PR_NUMBER" "$PR_TITLE"
+ else
+ printf 'Manual release by @%s\n' "$PR_AUTHOR"
+ fi
if [ -n "$ISSUES" ]; then
printf 'Resolves: %s\n' "$(echo "$ISSUES" | sed 's/,/, #/g; s/^/#/')"
fi
printf 'Author: @%s\n' "$PR_AUTHOR"
- printf 'Merge commit: %s\n' "$MERGE_SHA"
+ printf 'Commit: %s\n' "$MERGE_SHA"
} > tag-message.txt
git tag -a "$VERSION" -F tag-message.txt
git push origin "$VERSION"
+ echo "result=created" >> "$GITHUB_OUTPUT"
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- - name: Label referenced issues πŸ›©οΈ
+ - name: πŸ›©οΈ Label referenced issues
id: label
- if: steps.check_pr.outputs.needs_tag == 'true' && steps.issues.outputs.numbers != ''
+ if: >-
+ env.IS_MANUAL != 'true'
+ && steps.check_pr.outputs.needs_tag == 'true'
+ && steps.issues.outputs.numbers != ''
continue-on-error: true
uses: actions/github-script@v8
env:
@@ -234,53 +298,65 @@ jobs:
}
}
- - name: Trigger docs site rebuild πŸ“
+ - name: πŸ“ Trigger docs site rebuild
id: docs
- if: steps.tag.outcome == 'success'
+ if: steps.tag.outputs.result == 'created'
continue-on-error: true
env:
HOOK_URL: ${{ secrets.DOCS_SITE_REBUILD_HOOK }}
+ VERSION: ${{ steps.tag.outputs.version }}
run: |
+ set -euo pipefail
if [ -z "$HOOK_URL" ]; then
echo "::warning::DOCS_SITE_REBUILD_HOOK secret is not set, skipping"
exit 1
fi
- VERSION=$(node -p "require('./package.json').version" 2>/dev/null || echo "unknown")
curl -sf -X POST -d '{}' "${HOOK_URL}?trigger_title=v${VERSION}+released" \
--max-time 15 --retry 2 --retry-max-time 30
echo "Triggered docs rebuild for v${VERSION}"
- - name: Job summary πŸ“‹
+ - name: πŸ“‹ Job summary
if: always()
env:
- PR_NUMBER: ${{ github.event.pull_request.number }}
- PR_TITLE: ${{ github.event.pull_request.title }}
+ PR_NUMBER: ${{ github.event.pull_request.number || '' }}
+ PR_TITLE: ${{ github.event.pull_request.title || '' }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
NEEDS_BUMP: ${{ steps.check_pr.outputs.needs_bump }}
NEEDS_TAG: ${{ steps.check_pr.outputs.needs_tag }}
ISSUES: ${{ steps.issues.outputs.numbers }}
+ BUMPED: ${{ steps.bump.outputs.bumped }}
TAG_OUTCOME: ${{ steps.tag.outcome }}
+ TAG_RESULT: ${{ steps.tag.outputs.result }}
+ TAG_VERSION: ${{ steps.tag.outputs.version }}
LABEL_OUTCOME: ${{ steps.label.outcome }}
DOCS_OUTCOME: ${{ steps.docs.outcome }}
run: |
- VERSION=$(node -p "require('./package.json').version" 2>/dev/null || echo "unknown")
+ set -euo pipefail
+ VERSION="${TAG_VERSION:-$(node -p "require('./package.json').version" 2>/dev/null || echo "unknown")}"
{
echo "## πŸ”– Auto Version & Tag"
echo ""
echo "| Step | Result |"
echo "|------|--------|"
- echo "| PR | [#${PR_NUMBER}](${REPO_URL}/pull/${PR_NUMBER}) β€” ${PR_TITLE} |"
- if [ "$NEEDS_BUMP" = "true" ]; then
+ if [ "$IS_MANUAL" = "true" ]; then
+ echo "| Trigger | Manual dispatch |"
+ elif [ -n "$PR_NUMBER" ]; then
+ echo "| PR | [#${PR_NUMBER}](${REPO_URL}/pull/${PR_NUMBER}) β€” ${PR_TITLE} |"
+ fi
+
+ if [ "$BUMPED" = "true" ]; then
echo "| Version bump | βœ… \`${VERSION}\` |"
else
echo "| Version bump | ⏭️ Skipped |"
fi
- if [ "$NEEDS_TAG" = "true" ] && [ "$TAG_OUTCOME" = "success" ]; then
+ if [ "$TAG_RESULT" = "created" ]; then
echo "| Tag | βœ… [\`${VERSION}\`](${REPO_URL}/releases/tag/${VERSION}) |"
- elif [ "$NEEDS_TAG" = "true" ]; then
+ elif [ "$TAG_RESULT" = "existed" ]; then
+ echo "| Tag | ⏭️ Already exists: \`${VERSION}\` |"
+ elif [ "$TAG_OUTCOME" = "failure" ]; then
echo "| Tag | ❌ Failed |"
else
echo "| Tag | ⏭️ Skipped |"