diff --git a/.github/actions/build-release-assets/action.yml b/.github/actions/build-release-assets/action.yml new file mode 100644 index 00000000..937bdcd4 --- /dev/null +++ b/.github/actions/build-release-assets/action.yml @@ -0,0 +1,24 @@ +name: Build release assets +description: Build and package the theme assets used by GitHub Releases and development builds. + +inputs: + bun-version: + description: Bun version used to build the theme. + required: false + default: "1.3.14" + +runs: + using: composite + steps: + - name: Set up Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: ${{ inputs.bun-version }} + + - name: Install dependencies + shell: bash + run: bun install --frozen-lockfile + + - name: Build and package theme assets + shell: bash + run: bash "${{ github.action_path }}/package.sh" diff --git a/.github/actions/build-release-assets/package.sh b/.github/actions/build-release-assets/package.sh new file mode 100644 index 00000000..3c3a77c1 --- /dev/null +++ b/.github/actions/build-release-assets/package.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +bun release + +tar -zcf dist/theme-github-base.tar.gz \ + dist/theme-github-auto.css dist/theme-github-light.css dist/theme-github-dark.css dist/theme-github-soft-dark.css + +tar -zcf dist/theme-github-colorblind-protanopia-deuteranopia.tar.gz dist/theme-github-colorblind-*.css +tar -zcf dist/theme-github-colorblind-tritanopia.tar.gz dist/theme-github-tritanopia-*.css + +tar -zcf dist/theme-github-high-contrast-base.tar.gz \ + dist/theme-github-high-contrast-auto.css dist/theme-github-high-contrast-light.css \ + dist/theme-github-high-contrast-dark.css dist/theme-github-high-contrast-soft-dark.css + +tar -zcf dist/theme-github-high-contrast-colorblind-protanopia-deuteranopia.tar.gz \ + dist/theme-github-high-contrast-colorblind-*.css +tar -zcf dist/theme-github-high-contrast-colorblind-tritanopia.tar.gz \ + dist/theme-github-high-contrast-tritanopia-*.css + +tar -zcf dist/theme-github-extra-pink.tar.gz dist/theme-github-pink-*.css +tar -zcf dist/theme-github-extra-gitea.tar.gz dist/theme-github-gitea-*.css +tar -zcf dist/theme-github-extra-catppuccin.tar.gz dist/theme-github-catppuccin-*.css + +tar -zcf dist/theme-github.tar.gz --remove-files dist/theme-github-*.css + +tar -zcf dist/theme-github-templates.tar.gz templates +tar -zcf dist/theme-github-fonts.tar.gz -C dist assets/fonts +tar -zcf dist/theme-github-translations.tar.gz --remove-files dist/options diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..2818b10d --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,60 @@ +name-template: "$RESOLVED_VERSION" +tag-template: "$RESOLVED_VERSION" +change-template: "* $TITLE by @$AUTHOR in [#$NUMBER]($URL)" +change-title-escapes: "\\<*_&" +category-template: "## $TITLE" +no-changes-template: "* No changes" + +template: | + # Release $RESOLVED_VERSION + + + [Short summary of the release.] + + # Compatibility + + This release targets Forgejo `[major version]`. + + It was tested against Forgejo `[version]`, including the bundled template overrides. + + # Changelog + + $CHANGES + +categories: + - title: "Features" + exclusive: true + labels: + - "feature" + + - title: "Changes" + exclusive: true + labels: + - "change" + + - title: "Fixes" + exclusive: true + labels: + - "bug" + + - title: "Dependencies" + exclusive: true + labels: + - "dependencies" + +exclude-labels: + - "skip-changelog" + +version-resolver: + major: + labels: + - "major" + minor: + labels: + - "feature" + patch: + labels: + - "change" + - "bug" + - "dependencies" + default: patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 46b6cde2..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: build - -on: - push: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: dorny/paths-filter@v4 - id: changes - with: - filters: | - src: - - ".github/workflows/*.yml" - - "primer/**/*.ts" - - "scripts/*" - - "src/**/*.ts" - - "styles/**/*.ts" - - "templates/**" - - "themes/*.ts" - - "public/**" - - "theme.config.ts" - - "vite.config.ts" - - "package.json" - - - uses: oven-sh/setup-bun@v2 - with: - bun-version: "1.3.14" - - - name: Build theme - id: build - if: steps.changes.outputs.src == 'true' - run: | - bun install - bun bundle:ci - - - name: Upload css assets - if: steps.build.outcome == 'success' - uses: actions/upload-artifact@v7 - with: - name: themes - path: dist/*.css - - - name: Upload templates assets - if: steps.build.outcome == 'success' - uses: actions/upload-artifact@v7 - with: - name: templates - path: templates - - - name: Upload font assets - if: steps.build.outcome == 'success' - uses: actions/upload-artifact@v7 - with: - name: fonts - path: dist/assets/fonts - - - name: Build locales - id: locales - if: steps.build.outcome =='success' - continue-on-error: true - run: bun update:locale - - - name: Upload locales assets - if: steps.locales.outcome =='success' - uses: actions/upload-artifact@v7 - with: - name: locales - path: dist/options/locale diff --git a/.github/workflows/development-build.yml b/.github/workflows/development-build.yml new file mode 100644 index 00000000..8a7df174 --- /dev/null +++ b/.github/workflows/development-build.yml @@ -0,0 +1,33 @@ +name: Development Build + +on: + workflow_dispatch: + inputs: + ref: + description: Branch, tag, or commit to build. + required: true + default: dev + type: string + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out source + uses: actions/checkout@v7 + with: + ref: ${{ inputs.ref }} + + - name: Build release assets + uses: ./.github/actions/build-release-assets + + - name: Upload development artifacts + uses: actions/upload-artifact@v7 + with: + name: forgejo-theme-dev-${{ github.run_number }} + path: dist/*.tar.gz + if-no-files-found: error + retention-days: 14 diff --git a/.github/workflows/pr.yml b/.github/workflows/pull-request.yml similarity index 59% rename from .github/workflows/pr.yml rename to .github/workflows/pull-request.yml index 919c9e57..9927940a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pull-request.yml @@ -1,12 +1,52 @@ -name: pr +name: Pull Request on: pull_request: + types: + - opened + - edited + - reopened + - synchronize + - ready_for_review branches: - - main + - dev + pull_request_target: + types: + - opened + - edited + - reopened + - synchronize + - labeled + - unlabeled + - ready_for_review + branches: + - dev + +concurrency: + group: pr-${{ github.event_name }}-${{ github.event.pull_request.number }} + cancel-in-progress: true jobs: + require-release-label: + if: github.event_name == 'pull_request_target' + runs-on: ubuntu-latest + permissions: + issues: read + pull-requests: read + steps: + - name: Verify pull request release label + uses: mheap/github-action-required-labels@v5 + with: + mode: exactly + count: 1 + labels: "^(feature|change|bug|dependencies|skip-changelog)$" + use_regex: true + message: >- + Add one release label: feature, change, bug, dependencies, or skip-changelog. Add major as an optional + version modifier. + checks: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml new file mode 100644 index 00000000..cbcd3568 --- /dev/null +++ b/.github/workflows/release-build.yml @@ -0,0 +1,35 @@ +name: Release Build + +on: + release: + types: + - created + - published + workflow_dispatch: + inputs: + release-tag: + description: Release tag to rebuild and republish, for example v1.28.0 + required: true + type: string + +permissions: + contents: write + +concurrency: + group: release-${{ github.event.release.tag_name || inputs.release-tag }} + cancel-in-progress: true + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.release-tag }} + - name: Build release assets + uses: ./.github/actions/build-release-assets + - name: Upload assets to release + env: + GH_TOKEN: ${{ github.token }} + RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.release-tag }} + run: gh release upload "$RELEASE_TAG" dist/*.tar.gz --clobber diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..d4ab36e0 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,26 @@ +name: Release Drafter + +on: + push: + branches: + - dev + workflow_dispatch: + +permissions: + contents: write + pull-requests: read + +concurrency: + group: release-drafter-${{ github.ref }} + cancel-in-progress: true + +jobs: + update-release-draft: + runs-on: ubuntu-latest + steps: + - name: Update release draft + uses: release-drafter/release-drafter@v7 + with: + commitish: dev + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 88d5294a..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: release - -on: - workflow_dispatch: - -permissions: - contents: write - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: oven-sh/setup-bun@v2 - with: - bun-version: "1.3.14" - - name: Build theme - run: | - bun install - bun release - - name: Create release - run: | - tar -zcf dist/theme-github-base.tar.gz \ - dist/theme-github-auto.css dist/theme-github-light.css dist/theme-github-dark.css dist/theme-github-soft-dark.css - - tar -zcf dist/theme-github-colorblind-protanopia-deuteranopia.tar.gz dist/theme-github-colorblind-*.css - tar -zcf dist/theme-github-colorblind-tritanopia.tar.gz dist/theme-github-tritanopia-*.css - - tar -zcf dist/theme-github-high-contrast-base.tar.gz \ - dist/theme-github-high-contrast-auto.css dist/theme-github-high-contrast-light.css dist/theme-github-high-contrast-dark.css dist/theme-github-high-contrast-soft-dark.css - - tar -zcf dist/theme-github-high-contrast-colorblind-protanopia-deuteranopia.tar.gz dist/theme-github-high-contrast-colorblind-*.css - tar -zcf dist/theme-github-high-contrast-colorblind-tritanopia.tar.gz dist/theme-github-high-contrast-tritanopia-*.css - - tar -zcf dist/theme-github-extra-pink.tar.gz dist/theme-github-pink-*.css - tar -zcf dist/theme-github-extra-gitea.tar.gz dist/theme-github-gitea-*.css - tar -zcf dist/theme-github-extra-catppuccin.tar.gz dist/theme-github-catppuccin-*.css - - tar -zcf dist/theme-github.tar.gz --remove-files dist/theme-github-*.css - - tar -zcf dist/theme-github-templates.tar.gz templates - tar -zcf dist/theme-github-fonts.tar.gz -C dist assets/fonts - tar -zcf dist/theme-github-translations.tar.gz --remove-files dist/options - - TAG="v$(npm run -s version)" - gh release create "$TAG" dist/*.tar.gz --notes-file CHANGELOG.md --draft -t $TAG - env: - GH_TOKEN: ${{ github.token }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff662fae..60871d56 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,6 +39,22 @@ If you believe you have a better approach, feel free to submit an Issue. > > When submitting a PR, please run `bun commit` +### Pull Requests and Release Notes + +Submit changes through a pull request targeting `dev`. Use a specific, release-note-friendly title in the form +`Area: Description`, for example `Templates: Fix commit status badge rendering`. + +Apply exactly one primary release label: + +- `feature` for new user-facing capabilities or themes +- `change` for intentional style, template, or compatibility improvements +- `bug` for regressions and incorrect rendering +- `dependencies` for dependency and build-tool updates +- `skip-changelog` for internal changes that should not appear in release notes + +Add `major` when the change requires a major version bump. It modifies version resolution but does not create a separate +release-notes section. + ## Development Environment The theme depends on the Bun runtime. Please ensure Bun is installed in your environment. Bun 1.3.14 or later is