diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index ba31e3b..4761a31 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -15,7 +15,7 @@ jobs: with: fetch-depth: 0 - - name: Stop if this is the bot changelog commit + - name: Stop if this is the bot changelog/version commit shell: bash run: | set -e @@ -36,58 +36,6 @@ jobs: sudo install /tmp/git-cliff-*/git-cliff /usr/local/bin/git-cliff git-cliff --version - - name: Generate CHANGELOG.md (Keep a Changelog) - shell: bash - run: | - set -e - git-cliff --config cliff.toml --output CHANGELOG.md - test -s CHANGELOG.md - - - name: Commit and push CHANGELOG.md if changed (CHANGELOG_PAT) - shell: bash - env: - CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }} - run: | - set -e - - if git diff --quiet -- CHANGELOG.md; then - echo "No changelog changes." - else - git config user.name "changelog-bot" - git config user.email "changelog-bot@users.noreply.local" - - git add CHANGELOG.md - git commit -m "docs(changelog): update changelog [skip ci]" - - origin_url="$(git remote get-url origin)" - - # Convert SSH origin to HTTPS if needed - if echo "$origin_url" | grep -q "^git@"; then - host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')" - path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')" - origin_url="https://$host/$path" - fi - - authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")" - git push "$authed_url" HEAD:main - fi - - - name: Extract newest changelog section for release body - shell: bash - run: | - set -e - awk ' - /^## / { if (seen) exit; seen=1 } - seen { print } - ' CHANGELOG.md > RELEASE_NOTES.md - - sed -i 's/[[:space:]]*$//' RELEASE_NOTES.md - - test -s RELEASE_NOTES.md - echo "---- RELEASE_NOTES.md ----" - head -n 60 RELEASE_NOTES.md - echo "--------------------------" - - name: Prepare YY.MM.DD letter-suffix tag + release name shell: bash run: | @@ -139,13 +87,87 @@ jobs: echo "Release name: $RELEASE_NAME" echo "Release URL: $RELEASE_URL" + - name: Find previous release tag + shell: bash + run: | + set -e + + PREV_TAG="$( + git tag --list 'v*' \ + | grep -E '^v[0-9]{2}\.[0-9]{2}\.[0-9]{2}[a-z]$' \ + | sort -V \ + | tail -n 1 + )" + + if [ -n "$PREV_TAG" ]; then + echo "PREV_TAG=$PREV_TAG" >> "$GITHUB_ENV" + echo "Previous release tag: $PREV_TAG" + else + echo "PREV_TAG=" >> "$GITHUB_ENV" + echo "No previous release tag found." + fi + + - name: Generate CHANGELOG.md from previous release to HEAD + shell: bash + run: | + set -e + + if [ -n "${PREV_TAG}" ]; then + echo "Generating changelog from ${PREV_TAG}..HEAD" + git-cliff --config cliff.toml "${PREV_TAG}..HEAD" --output CHANGELOG.md + else + echo "Generating changelog from full history" + git-cliff --config cliff.toml --output CHANGELOG.md + fi + + test -s CHANGELOG.md + echo "---- CHANGELOG.md ----" + head -n 120 CHANGELOG.md + echo "----------------------" + + - name: Commit and push CHANGELOG.md if changed (CHANGELOG_PAT) + shell: bash + env: + CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }} + run: | + set -e + + if git diff --quiet -- CHANGELOG.md; then + echo "No changelog changes." + else + git config user.name "changelog-bot" + git config user.email "changelog-bot@users.noreply.local" + + git add CHANGELOG.md + git commit -m "docs(changelog): update changelog [skip ci]" + + origin_url="$(git remote get-url origin)" + + if echo "$origin_url" | grep -q "^git@"; then + host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')" + path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')" + origin_url="https://$host/$path" + fi + + authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")" + git push "$authed_url" HEAD:main + fi + + - name: Prepare release notes + shell: bash + run: | + set -e + cp CHANGELOG.md RELEASE_NOTES.md + test -s RELEASE_NOTES.md + echo "---- RELEASE_NOTES.md ----" + head -n 120 RELEASE_NOTES.md + echo "--------------------------" + - name: Derive semver package version from tag shell: bash run: | set -e - # Convert: - # v25.03.21a -> 25.3.21-a PACKAGE_VERSION="$(echo "$TAG" | sed -E 's/^v([0-9]{2})\.0?([0-9]{1,2})\.0?([0-9]{1,2})([a-z])$/\1.\2.\3-\4/')" if [ -z "$PACKAGE_VERSION" ]; then @@ -174,9 +196,15 @@ jobs: - name: Set up Node uses: actions/setup-node@v6 with: - node-version: 25 + node-version: 22.12.0 cache: npm + - name: Check Node version + shell: bash + run: | + node -v + npm -v + - name: Install dependencies shell: bash run: | @@ -195,6 +223,34 @@ jobs: echo "package-lock.json version:" node -p "require('./package-lock.json').version" + - name: Commit and push version bump (CHANGELOG_PAT) + shell: bash + env: + CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }} + run: | + set -e + + if git diff --quiet -- package.json package-lock.json; then + echo "No version changes to commit." + else + git config user.name "release-bot" + git config user.email "release-bot@users.noreply.local" + + git add package.json package-lock.json + git commit -m "chore(release): bump version to ${PACKAGE_VERSION} [skip ci]" + + origin_url="$(git remote get-url origin)" + + if echo "$origin_url" | grep -q "^git@"; then + host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')" + path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')" + origin_url="https://$host/$path" + fi + + authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")" + git push "$authed_url" HEAD:main + fi + - name: Build Astro site shell: bash run: | @@ -306,34 +362,4 @@ jobs: -F "attachment=@${ZIP_PATH}" \ >/dev/null - echo "✅ Release created: ${RELEASE_NAME} (tag: ${TAG}) with asset uploaded" - - - name: Commit and push version bump (CHANGELOG_PAT) - shell: bash - env: - CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }} - run: | - set -e - - if git diff --quiet -- package.json package-lock.json; then - echo "No version changes to commit." - else - git config user.name "release-bot" - git config user.email "release-bot@users.noreply.local" - - git add package.json package-lock.json - git commit -m "chore(release): bump version to ${PACKAGE_VERSION} [skip ci]" - - origin_url="$(git remote get-url origin)" - - # Convert SSH → HTTPS if needed - if echo "$origin_url" | grep -q "^git@"; then - host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')" - path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')" - origin_url="https://$host/$path" - fi - - authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")" - - git push "$authed_url" HEAD:main - fi \ No newline at end of file + echo "✅ Release created: ${RELEASE_NAME} (tag: ${TAG}) with asset uploaded" \ No newline at end of file diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..e372353 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,35 @@ +[changelog] +header = """ +# Changelog +""" + +body = """ +{% for group, commits in commits | group_by(attribute="group") %} +## {{ group }} +{% for commit in commits %} +- {{ commit.message | upper_first }} +{% endfor %} +{% endfor %} +""" + +footer = "" + +[git] +conventional_commits = false +filter_unconventional = false +split_commits = false +topo_order = true + +# IMPORTANT: match your tag format +tag_pattern = "^v[0-9]{2}\\.[0-9]{2}\\.[0-9]{2}[a-z]$" + +commit_parsers = [ + { message = "^feat", group = "🚀 Features" }, + { message = "^fix", group = "🐛 Fixes" }, + { message = "^refactor", group = "♻️ Refactoring" }, + { message = "^docs", group = "📚 Documentation" }, + { message = "^chore", group = "💼 Other" }, + + # catch-all so NOTHING is dropped + { message = ".*", group = "💼 Other" }, +] \ No newline at end of file diff --git a/src/generated/version.json b/src/generated/version.json new file mode 100644 index 0000000..a27f29d --- /dev/null +++ b/src/generated/version.json @@ -0,0 +1,4 @@ +{ + "version": "dev", + "url": "#" +} \ No newline at end of file diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 3dafc7a..bc9baa0 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -64,13 +64,10 @@ const { title = "Computing:Box" } = Astro.props; Legal Code