build(fix): update release setup
1 files copied
2 files modified
1 files renamed
1 files added
| New file |
| | |
| | | name: Release |
| | | |
| | | on: |
| | | workflow_dispatch: |
| | | |
| | | permissions: |
| | | contents: write |
| | | id-token: write |
| | | |
| | | concurrency: |
| | | group: release-main |
| | | cancel-in-progress: false |
| | | |
| | | jobs: |
| | | release: |
| | | name: Release from main |
| | | runs-on: ubuntu-latest |
| | | |
| | | environment: |
| | | name: production |
| | | |
| | | if: github.ref == 'refs/heads/main' |
| | | |
| | | steps: |
| | | - name: Checkout repository |
| | | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| | | with: |
| | | fetch-depth: 0 |
| | | persist-credentials: true |
| | | |
| | | - name: Setup Node.js |
| | | uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e |
| | | with: |
| | | node-version: 22 |
| | | registry-url: "https://registry.npmjs.org" |
| | | |
| | | - name: Install dependencies |
| | | run: npm ci |
| | | |
| | | - name: Run checks |
| | | run: npm test |
| | | |
| | | - name: Release |
| | | env: |
| | | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| | | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| | | run: npm run release |
| File was renamed from .release-it.ts |
| | |
| | | const branch = getCurrentBranch(); |
| | | const isPreRelease = hasPreReleaseFlag(process.argv); |
| | | |
| | | if (isPreRelease && branch !== "development") { |
| | | if (isPreRelease && branch !== "staging") { |
| | | console.error( |
| | | `Pre-releases are only allowed from "development". Current branch: "${branch}".`, |
| | | `Pre-releases are only allowed from "staging". Current branch: "${branch}".`, |
| | | ); |
| | | process.exit(1); |
| | | } |
| | | |
| | | if (!isPreRelease && branch !== "main") { |
| | | if (!isPreRelease && branch !== "maintenance" && branch !== "staging") { |
| | | console.error( |
| | | `Stable releases are only allowed from "main". Current branch: "${branch}".`, |
| | | `Stable releases are only allowed from "maintenance" and "staging". Current branch: "${branch}".`, |
| | | ); |
| | | process.exit(1); |
| | | } |
| | |
| | | commit: true, |
| | | commitMessage: "chore(release): v${version}", |
| | | commitArgs: ["--no-verify"], |
| | | tag: true, |
| | | tagName: "v${version}", |
| | | tag: false, |
| | | push: true, |
| | | pushArgs: ["--follow-tags"], |
| | | }, |
| | | github: { |
| | | release: true, |
| | | releaseName: "v${version}", |
| | | skipChecks: true, |
| | | tokenRef: "GITHUB_ANANKE_TOKEN_ADMIN_PRIVATE", |
| | | release: false, |
| | | }, |
| | | npm: { |
| | | publish: false, |
copy from .release-it.ts
copy to .release-it.publish.ts
| File was copied from .release-it.ts |
| | |
| | | import { execSync } from "node:child_process"; |
| | | import type { Config } from "release-it"; |
| | | |
| | | interface ConventionalCommitLike { |
| | |
| | | notes?: unknown[]; |
| | | } |
| | | |
| | | function getCurrentBranch(): string { |
| | | try { |
| | | return execSync("git rev-parse --abbrev-ref HEAD", { |
| | | encoding: "utf8", |
| | | stdio: ["ignore", "pipe", "pipe"], |
| | | }).trim(); |
| | | } catch (error) { |
| | | console.error("Failed to determine the current Git branch."); |
| | | console.error(error); |
| | | process.exit(1); |
| | | } |
| | | } |
| | | |
| | | function hasPreReleaseFlag(argv: string[]): boolean { |
| | | return argv.some((argument) => { |
| | | return ( |
| | | argument === "--preRelease" || |
| | | argument.startsWith("--preRelease=") || |
| | | argument === "--preReleaseId" || |
| | | argument.startsWith("--preReleaseId=") |
| | | ); |
| | | }); |
| | | } |
| | | |
| | | const branch = getCurrentBranch(); |
| | | const isPreRelease = hasPreReleaseFlag(process.argv); |
| | | |
| | | if (isPreRelease && branch !== "development") { |
| | | console.error( |
| | | `Pre-releases are only allowed from "development". Current branch: "${branch}".`, |
| | | ); |
| | | process.exit(1); |
| | | } |
| | | |
| | | if (!isPreRelease && branch !== "main") { |
| | | console.error( |
| | | `Stable releases are only allowed from "main". Current branch: "${branch}".`, |
| | | ); |
| | | process.exit(1); |
| | | } |
| | | |
| | | const config: Config = { |
| | | git: { |
| | | requireBranch: "main", |
| | | requireCleanWorkingDir: true, |
| | | requireUpstream: true, |
| | | requireCommits: true, |
| | | requireBranch: branch, |
| | | commit: true, |
| | | commitMessage: "chore(release): v${version}", |
| | | commitArgs: ["--no-verify"], |
| | | commit: false, |
| | | tag: true, |
| | | tagName: "v${version}", |
| | | push: true, |
| | | tagName: "v${version}", |
| | | pushArgs: ["--follow-tags"], |
| | | }, |
| | | github: { |
| | |
| | | }, |
| | | "explorer.fileNesting.enabled": true, |
| | | "explorer.fileNesting.patterns": { |
| | | "package.json": "package-lock.json, netlify.toml, .lintstagedrc.js, .release-it.ts, .markdownlint*, .nvmrc, lychee.toml, tsconfig.json, .coderabbit.yaml", |
| | | "package.json": "package-lock.json, netlify.toml, .lintstagedrc.js, .release-it.*.ts, .markdownlint*, .nvmrc, lychee.toml, tsconfig.json, .coderabbit.yaml", |
| | | "theme.toml": "go.mod, go.sum", |
| | | "README.md": "CHANGELOG.md, LICENSE.md, CONTRIBUTING.md, RELEASES.md, DESIGN.md" |
| | | }, |
| | |
| | | "lint:markdown": "markdownlint-cli2", |
| | | "lint:markdown:fix": "markdownlint-cli2 --fix", |
| | | "prepare": "simple-git-hooks install", |
| | | "release": "release-it --config .release-it.ts", |
| | | "release:pre": "release-it --preRelease=prerelease --config .release-it.ts", |
| | | "release:pre": "release-it --preRelease=prerelease --config .release-it.publish.ts --ci", |
| | | "release:prepare": "release-it --config .release-it.prepare.ts", |
| | | "release": "release-it --config .release-it.publish.ts --ci", |
| | | "server": "hugo server --environment documentation", |
| | | "test": "node scripts/test-hugo-quickstart.ts", |
| | | "test:quickstart": "node scripts/test-hugo-quickstart.ts", |