@seangalie/precast 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +202 -0
  3. package/README.md +217 -2
  4. package/dist/bin.d.ts +2 -0
  5. package/dist/bin.js +3 -0
  6. package/dist/cli.d.ts +1 -0
  7. package/dist/cli.js +140 -0
  8. package/dist/collect.d.ts +17 -0
  9. package/dist/collect.js +143 -0
  10. package/dist/context.d.ts +32 -0
  11. package/dist/context.js +159 -0
  12. package/dist/errors.d.ts +8 -0
  13. package/dist/errors.js +8 -0
  14. package/dist/fnmatch.d.ts +9 -0
  15. package/dist/fnmatch.js +110 -0
  16. package/dist/generate.d.ts +17 -0
  17. package/dist/generate.js +67 -0
  18. package/dist/index.d.ts +6 -0
  19. package/dist/index.js +6 -0
  20. package/dist/output-path.d.ts +30 -0
  21. package/dist/output-path.js +84 -0
  22. package/dist/platforms.d.ts +17 -0
  23. package/dist/platforms.js +62 -0
  24. package/dist/tiers.d.ts +23 -0
  25. package/dist/tiers.js +96 -0
  26. package/package.json +44 -4
  27. package/platforms/forgejo/files/.forgejo/CODEOWNERS.tmpl +2 -0
  28. package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/01_bug_report.yml.tmpl +83 -0
  29. package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/02_feature_request.yml.tmpl +57 -0
  30. package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/03_codebase_improvement.yml.tmpl +44 -0
  31. package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/04_support_question.yml.tmpl +47 -0
  32. package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/config.yml.tmpl +13 -0
  33. package/platforms/forgejo/files/.forgejo/PULL_REQUEST_TEMPLATE.md.tmpl +49 -0
  34. package/platforms/forgejo/files/.forgejo/SETUP.md.tmpl +61 -0
  35. package/platforms/forgejo/files/.forgejo/labels.yml.tmpl +99 -0
  36. package/platforms/forgejo/files/.forgejo/scripts/check-labels.sh.tmpl +91 -0
  37. package/platforms/forgejo/files/.forgejo/scripts/sync-labels.sh.tmpl +165 -0
  38. package/platforms/forgejo/files/.forgejo/workflows/labels.yml.tmpl +45 -0
  39. package/platforms/forgejo/files/.forgejo/workflows/lint.yml.tmpl +78 -0
  40. package/platforms/forgejo/files/.forgejo/workflows/pr-labels.yml.tmpl +51 -0
  41. package/platforms/forgejo/files/.forgejo/workflows/pre-commit.yml.tmpl +24 -0
  42. package/platforms/forgejo/files/.forgejo/workflows/release.yml.tmpl +130 -0
  43. package/platforms/forgejo/files/.forgejo/workflows/renovate.yml.tmpl +61 -0
  44. package/platforms/forgejo/files/.forgejo/workflows/stale.yml.tmpl +260 -0
  45. package/platforms/forgejo/files/renovate.json +36 -0
  46. package/platforms/forgejo/platform.json +41 -0
  47. package/platforms/github/files/.github/CODEOWNERS.tmpl +2 -0
  48. package/platforms/github/files/.github/ISSUE_TEMPLATE/01_bug_report.yml.tmpl +83 -0
  49. package/platforms/github/files/.github/ISSUE_TEMPLATE/02_feature_request.yml.tmpl +57 -0
  50. package/platforms/github/files/.github/ISSUE_TEMPLATE/03_codebase_improvement.yml.tmpl +44 -0
  51. package/platforms/github/files/.github/ISSUE_TEMPLATE/04_support_question.yml.tmpl +47 -0
  52. package/platforms/github/files/.github/ISSUE_TEMPLATE/config.yml.tmpl +16 -0
  53. package/platforms/github/files/.github/PULL_REQUEST_TEMPLATE.md.tmpl +49 -0
  54. package/platforms/github/files/.github/SETUP.md.tmpl +46 -0
  55. package/platforms/github/files/.github/dependabot.yml.tmpl +75 -0
  56. package/platforms/github/files/.github/labels.yml.tmpl +103 -0
  57. package/platforms/github/files/.github/release.yml.tmpl +47 -0
  58. package/platforms/github/files/.github/workflows/ci.yml.tmpl +55 -0
  59. package/platforms/github/files/.github/workflows/codeql.yml.tmpl +63 -0
  60. package/platforms/github/files/.github/workflows/labels.yml.tmpl +34 -0
  61. package/platforms/github/files/.github/workflows/lint-workflows.yml.tmpl +75 -0
  62. package/platforms/github/files/.github/workflows/lint.yml.tmpl +69 -0
  63. package/platforms/github/files/.github/workflows/lock.yml.tmpl +46 -0
  64. package/platforms/github/files/.github/workflows/pr-labels.yml.tmpl +26 -0
  65. package/platforms/github/files/.github/workflows/pre-commit.yml.tmpl +25 -0
  66. package/platforms/github/files/.github/workflows/release.yml.tmpl +101 -0
  67. package/platforms/github/files/.github/workflows/stale.yml.tmpl +57 -0
  68. package/platforms/github/platform.json +44 -0
  69. package/platforms/gitlab/files/.gitlab/CODEOWNERS.tmpl +2 -0
  70. package/platforms/gitlab/files/.gitlab/SETUP.md.tmpl +62 -0
  71. package/platforms/gitlab/files/.gitlab/issue_templates/01_bug_report.md +18 -0
  72. package/platforms/gitlab/files/.gitlab/issue_templates/02_feature_request.md +11 -0
  73. package/platforms/gitlab/files/.gitlab/issue_templates/03_codebase_improvement.md +11 -0
  74. package/platforms/gitlab/files/.gitlab/issue_templates/04_support_question.md +12 -0
  75. package/platforms/gitlab/files/.gitlab/labels.json +122 -0
  76. package/platforms/gitlab/files/.gitlab/merge_request_templates/Default.md +14 -0
  77. package/platforms/gitlab/files/.gitlab/scripts/project.py +159 -0
  78. package/platforms/gitlab/files/.gitlab-ci.yml.tmpl +54 -0
  79. package/platforms/gitlab/platform.json +34 -0
  80. package/template/.editorconfig.tmpl +54 -0
  81. package/template/.gitattributes +107 -0
  82. package/template/.gitignore.tmpl +244 -0
  83. package/template/.pre-commit-config.yaml.tmpl +43 -0
  84. package/template/.repo/check-secrets.py +40 -0
  85. package/template/.repo/ci-checks.sh +18 -0
  86. package/template/AGENTS.md.tmpl +75 -0
  87. package/template/CHANGELOG.md.tmpl +24 -0
  88. package/template/CLAUDE.md +1 -0
  89. package/template/LICENSE +202 -0
  90. package/template/README.md.tmpl +101 -0
  91. package/template/SETUP.md.tmpl +47 -0
  92. package/template/docs/CODE_OF_CONDUCT.md +85 -0
  93. package/template/docs/CONTRIBUTING.md.tmpl +54 -0
  94. package/template/docs/SECURITY.md.tmpl +26 -0
  95. package/template/docs/SUPPORT.md.tmpl +19 -0
  96. package/template/docs/logo.svg +84 -0
  97. package/template/docs/screenshot.png +0 -0
  98. package/tiers.json +10 -0
@@ -0,0 +1,130 @@
1
+ ---
2
+ # Publishes a Forgejo release when a version tag is pushed, using that
3
+ # version's section of CHANGELOG.md as the release notes.
4
+ #
5
+ # git tag -a v1.2.0 -m "v1.2.0" && git push origin v1.2.0
6
+ #
7
+ # The tag v1.2.0 picks the `## [1.2.0] - YYYY-MM-DD` section. A tag with a
8
+ # pre-release suffix such as v1.2.0-rc.1 is published as a pre-release. Pushing
9
+ # the same tag again (after deleting it) updates the existing release's notes.
10
+ #
11
+ # The run fails, publishing nothing, if CHANGELOG.md has no section for the
12
+ # version or the repository's Releases unit is switched off.
13
+ #
14
+ # This only writes the release notes. Build and attach artifacts in a job of
15
+ # your own, uploading to the release this job creates.
16
+
17
+ name: Release
18
+
19
+ on:
20
+ push:
21
+ tags:
22
+ - "v*"
23
+
24
+ jobs:
25
+ release:
26
+ name: 📦 Publish the release
27
+ runs-on: @@RUNNER_YAML@@
28
+ env:
29
+ FORGEJO_API: ${{ github.api_url }}
30
+ FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31
+ REPO_FULL: ${{ github.repository }}
32
+ TAG: ${{ github.ref_name }}
33
+ steps:
34
+ - name: ⤵️ Check out the repository
35
+ uses: https://data.forgejo.org/actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
36
+ with:
37
+ persist-credentials: false
38
+
39
+ - name: 🧰 Make sure jq is available
40
+ run: |
41
+ set -euo pipefail
42
+ command -v jq >/dev/null 2>&1 || {
43
+ apt-get update -qq && apt-get install -y -qq jq
44
+ }
45
+
46
+ # With the unit off, every release endpoint answers 404, which the last
47
+ # step would read as "no release yet" and then fail to create one.
48
+ # Only an explicit false stops the run, so a server that does not
49
+ # report the field is not blocked.
50
+ - name: 🔎 Check that releases are enabled
51
+ run: |
52
+ set -euo pipefail
53
+ has_releases="$(curl --fail-with-body -sS \
54
+ -H "Authorization: token ${FORGEJO_TOKEN}" \
55
+ -H "Accept: application/json" \
56
+ "${FORGEJO_API}/repos/${REPO_FULL}" | jq -r '.has_releases')"
57
+ if [ "$has_releases" = "false" ]; then
58
+ echo "::error::The Releases unit is disabled for ${REPO_FULL}. Enable it under Settings → Units, then delete and re-push ${TAG}."
59
+ exit 1
60
+ fi
61
+
62
+ - name: 📝 Extract the release notes
63
+ run: |
64
+ set -euo pipefail
65
+ version="${TAG#v}"
66
+
67
+ # Everything under `## [<version>]` up to the next `## [` heading,
68
+ # without the link definitions Keep a Changelog puts at the end.
69
+ awk -v v="$version" '
70
+ /^## \[/ {
71
+ if (found) exit
72
+ if (index($0, "## [" v "]") == 1) { found = 1; next }
73
+ }
74
+ found && !/^\[[^]]+\]: / { print }
75
+ ' CHANGELOG.md > "${RUNNER_TEMP}/notes.md"
76
+
77
+ # Trim the blank lines around the section.
78
+ sed -i -e '/./,$!d' "${RUNNER_TEMP}/notes.md"
79
+ sed -i -e ':a' -e '/^\n*$/{$d;N;ba' -e '}' "${RUNNER_TEMP}/notes.md"
80
+
81
+ # A missing section usually means the release was tagged before
82
+ # CHANGELOG.md was prepared, so stop rather than publish without notes.
83
+ if [ ! -s "${RUNNER_TEMP}/notes.md" ]; then
84
+ echo "::error::CHANGELOG.md has no section for ${version}, so nothing was published. Add a \`## [${version}]\` section, then delete and re-push ${TAG}."
85
+ exit 1
86
+ fi
87
+
88
+ echo "----- Release notes for ${TAG} -----"
89
+ cat "${RUNNER_TEMP}/notes.md"
90
+ echo "------------------------------------"
91
+
92
+ - name: 🚀 Create or update the release
93
+ run: |
94
+ set -euo pipefail
95
+ OWNER="${REPO_FULL%%/*}"
96
+ REPO="${REPO_FULL##*/}"
97
+ BASE="${FORGEJO_API}/repos/${OWNER}/${REPO}"
98
+ AUTH=(-H "Authorization: token ${FORGEJO_TOKEN}" -H "Accept: application/json")
99
+
100
+ prerelease=false
101
+ case "${TAG#v}" in *-*) prerelease=true ;; esac
102
+
103
+ payload="$(jq -nc \
104
+ --arg tag "$TAG" \
105
+ --rawfile body "${RUNNER_TEMP}/notes.md" \
106
+ --argjson pre "$prerelease" \
107
+ '{tag_name: $tag, name: $tag, body: $body, draft: false, prerelease: $pre}')"
108
+
109
+ status="$(curl -sS -o "${RUNNER_TEMP}/existing.json" -w '%{http_code}' \
110
+ "${AUTH[@]}" "${BASE}/releases/tags/${TAG}")" || status="000"
111
+
112
+ case "$status" in
113
+ 200)
114
+ id="$(jq -r '.id' "${RUNNER_TEMP}/existing.json")"
115
+ curl --fail-with-body -sS -o /dev/null -X PATCH "${AUTH[@]}" \
116
+ -H "Content-Type: application/json" \
117
+ "${BASE}/releases/${id}" -d "$payload"
118
+ echo "Updated the existing release for ${TAG}."
119
+ ;;
120
+ 404)
121
+ curl --fail-with-body -sS -o /dev/null -X POST "${AUTH[@]}" \
122
+ -H "Content-Type: application/json" \
123
+ "${BASE}/releases" -d "$payload"
124
+ echo "Published the release for ${TAG}."
125
+ ;;
126
+ *)
127
+ echo "::error::Could not check for an existing release for ${TAG} (HTTP ${status})."
128
+ exit 1
129
+ ;;
130
+ esac
@@ -0,0 +1,61 @@
1
+ ---
2
+ # Forgejo has no Dependabot. Renovate is the usual replacement, and unlike
3
+ # Dependabot it is not a service the forge provides -- something has to run it.
4
+ # This workflow runs the official Renovate container against this repository.
5
+ # Both its readable version and its immutable image digest are pinned.
6
+ #
7
+ # BEFORE THIS WORKS, create a repository (or organization) secret named
8
+ # RENOVATE_TOKEN holding a Forgejo access token for a dedicated bot account.
9
+ # Grant repository read/write, issue read/write, user read and organization
10
+ # read -- the last even for a repository owned by a user: Renovate probes
11
+ # /api/v1/orgs/<owner> while initialising, and Forgejo answers 403 rather than
12
+ # 404 when the scope is missing, which fails the whole run. Projects using
13
+ # Forgejo packages also need package read. Without the secret the job logs a
14
+ # warning and stops rather than failing the run.
15
+ #
16
+ # Scopes only bound what the token may do, not which repositories the account
17
+ # can reach, so also add the bot account as a collaborator with write access.
18
+ #
19
+ # Renovate understands the full-URL `uses: https://data.forgejo.org/...` form
20
+ # Forgejo needs, so action pins are kept current with no regex manager.
21
+ #
22
+ # Once you have more than a handful of projects, a single shared Renovate
23
+ # instance driven from one admin repository is a better arrangement than this
24
+ # per-repository copy. See https://code.forgejo.org/renovate/renovate
25
+
26
+ name: Renovate
27
+
28
+ on:
29
+ schedule:
30
+ - cron: "0 5 * * 1"
31
+ workflow_dispatch:
32
+
33
+ jobs:
34
+ renovate:
35
+ name: 🔄 Update dependencies
36
+ runs-on: @@RUNNER_YAML@@
37
+ steps:
38
+ - name: 🔑 Check for the Renovate token
39
+ id: auth
40
+ env:
41
+ RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
42
+ run: |
43
+ set -euo pipefail
44
+ if [ -z "${RENOVATE_TOKEN:-}" ]; then
45
+ echo "::warning::RENOVATE_TOKEN is not set, so Renovate was skipped. Add the secret to enable dependency updates."
46
+ echo "enabled=false" >> "$GITHUB_OUTPUT"
47
+ else
48
+ echo "enabled=true" >> "$GITHUB_OUTPUT"
49
+ fi
50
+
51
+ - name: 🚀 Run Renovate
52
+ if: steps.auth.outputs.enabled == 'true'
53
+ uses: docker://ghcr.io/renovatebot/renovate:44.115.13@sha256:0c04185c9e7ea5284da22ea0b2a2c88dcd3687badd8feb6c71691659b380df9b
54
+ env:
55
+ RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
56
+ RENOVATE_PLATFORM: forgejo
57
+ RENOVATE_ENDPOINT: ${{ github.api_url }}
58
+ RENOVATE_REPOSITORIES: ${{ github.repository }}
59
+ RENOVATE_GIT_AUTHOR: "Renovate Bot <renovate@noreply.localhost>"
60
+ # Renovate reads renovate.json from the repository root.
61
+ LOG_LEVEL: info
@@ -0,0 +1,260 @@
1
+ ---
2
+ # Marks quiet issues and pull requests stale, then closes them if they stay
3
+ # quiet.
4
+ #
5
+ # actions/stale is built on GitHub's API client and does not work against
6
+ # Forgejo, so this walks /api/v1 directly. Forgejo exposes no lock endpoint,
7
+ # so stale items are closed but not locked.
8
+
9
+ name: Stale
10
+
11
+ on:
12
+ schedule:
13
+ - cron: "0 8 * * *"
14
+ workflow_dispatch:
15
+ issues:
16
+ types: [reopened, edited, assigned, unassigned, labeled, unlabeled]
17
+ issue_comment:
18
+ types: [created, edited]
19
+ pull_request:
20
+ types: [reopened, edited, assigned, unassigned, labeled, unlabeled, synchronize]
21
+ # Covers approvals, change requests and comment-only reviews, including an
22
+ # inline comment made outside a review, which Forgejo submits as a one-line
23
+ # comment review. Replies to an existing review thread arrive as
24
+ # issue_comment. pull_request_review_comment is deliberately absent: Forgejo
25
+ # raises it for the same comment reviews, so it would only run this twice.
26
+ pull_request_review:
27
+ types: [submitted]
28
+
29
+ jobs:
30
+ stale:
31
+ name: 🧹 Clean up stale issues and PRs
32
+ if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
33
+ runs-on: @@RUNNER_YAML@@
34
+ env:
35
+ FORGEJO_API: ${{ github.api_url }}
36
+ FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37
+ REPO_FULL: ${{ github.repository }}
38
+ DAYS_BEFORE_STALE: "60"
39
+ DAYS_BEFORE_CLOSE: "14"
40
+ STALE_LABEL: "stale"
41
+ # Comma-separated, matched exactly. Bugs and anything with a priority are
42
+ # triaged work that stays open until someone deals with it, however long
43
+ # that takes; the sweep is for questions and ideas that lost momentum.
44
+ EXEMPT_ISSUE_LABELS: >-
45
+ no-stale,in-progress,help-wanted,security,bug,
46
+ priority/critical,priority/high,priority/medium,priority/low
47
+ EXEMPT_PR_LABELS: "no-stale,in-progress,security"
48
+ # Forgejo clamps this to the instance's api.MAX_RESPONSE_ITEMS.
49
+ PAGE_LIMIT: "50"
50
+ # Only a backstop against a server that never returns an empty page.
51
+ MAX_PAGES: "100"
52
+ steps:
53
+ - name: 🧰 Make sure jq is available
54
+ run: |
55
+ set -euo pipefail
56
+ command -v jq >/dev/null 2>&1 || {
57
+ apt-get update -qq && apt-get install -y -qq jq
58
+ }
59
+
60
+ - name: 🚀 Sweep stale items
61
+ run: |
62
+ set -euo pipefail
63
+ OWNER="${REPO_FULL%%/*}"
64
+ REPO="${REPO_FULL##*/}"
65
+ BASE="${FORGEJO_API}/repos/${OWNER}/${REPO}"
66
+ AUTH=(-H "Authorization: token ${FORGEJO_TOKEN}" -H "Accept: application/json")
67
+
68
+ stale_before="$(date -u -d "${DAYS_BEFORE_STALE} days ago" +%Y-%m-%dT%H:%M:%SZ)"
69
+ close_before="$(date -u -d "${DAYS_BEFORE_CLOSE} days ago" +%Y-%m-%dT%H:%M:%SZ)"
70
+
71
+ stale_issue_message="There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
72
+
73
+ Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍
74
+
75
+ Because this issue is marked as stale, it will be closed in ${DAYS_BEFORE_CLOSE} days if no further activity occurs.
76
+
77
+ Thank you for your contributions!"
78
+
79
+ stale_pr_message="There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale.
80
+
81
+ This PR will be closed in ${DAYS_BEFORE_CLOSE} days if no further activity occurs.
82
+
83
+ Thank you for your contributions!"
84
+
85
+ comment() {
86
+ curl --fail-with-body -sS -o /dev/null -X POST "${AUTH[@]}" \
87
+ -H "Content-Type: application/json" \
88
+ "${BASE}/issues/$1/comments" \
89
+ -d "$(jq -nc --arg b "$2" '{body: $b}')"
90
+ }
91
+
92
+ # Collects every open item of the given type updated before $2.
93
+ #
94
+ # Pages until the server returns an empty page rather than until it
95
+ # returns a short one. Forgejo clamps `limit` to the instance's
96
+ # api.MAX_RESPONSE_ITEMS, so a page shorter than PAGE_LIMIT does not
97
+ # mean the last page -- treating it as the last one would silently
98
+ # sweep only the first page on an instance configured below 50.
99
+ #
100
+ # Warnings go to stderr because this function's stdout is the JSON
101
+ # its caller captures.
102
+ fetch() {
103
+ local kind="$1" before="$2" page=1 chunk count out="[]"
104
+ while [ "$page" -le "$MAX_PAGES" ]; do
105
+ chunk="$(curl --fail-with-body -sS "${AUTH[@]}" \
106
+ "${BASE}/issues?state=open&type=${kind}&before=${before}&page=${page}&limit=${PAGE_LIMIT}")"
107
+ count="$(printf '%s' "$chunk" | jq 'length')"
108
+ [ "$count" -eq 0 ] && break
109
+ out="$(jq -s '.[0] + .[1]' <(printf '%s' "$out") <(printf '%s' "$chunk"))"
110
+ page=$((page + 1))
111
+ done
112
+ if [ "$page" -gt "$MAX_PAGES" ]; then
113
+ echo "::warning::Stopped paging ${kind} after ${MAX_PAGES} pages; some quiet items were not considered in this run." >&2
114
+ fi
115
+ printf '%s' "$out"
116
+ }
117
+
118
+ marked=0
119
+ closed=0
120
+
121
+ sweep() {
122
+ local kind="$1" exempt="$2" message="$3" items
123
+ local exempt_json
124
+ # The list is folded YAML, so trim the spaces the line breaks
125
+ # leave behind.
126
+ exempt_json="$(printf '%s' "$exempt" \
127
+ | jq -Rc 'split(",") | map(gsub("^\\s+|\\s+$"; "")) | map(select(. != ""))')"
128
+
129
+ # Close: already carrying the stale label, still not exempt, and
130
+ # quiet since it was marked. Activity events remove the stale label
131
+ # in the unstale job below, restarting the full stale period.
132
+ items="$(fetch "$kind" "$close_before")"
133
+ while read -r number; do
134
+ [ -n "$number" ] || continue
135
+ curl --fail-with-body -sS -o /dev/null -X PATCH "${AUTH[@]}" \
136
+ -H "Content-Type: application/json" \
137
+ "${BASE}/issues/${number}" -d '{"state":"closed"}'
138
+ echo " closed #${number}"
139
+ closed=$((closed + 1))
140
+ done < <(printf '%s' "$items" | jq -r \
141
+ --arg s "$STALE_LABEL" --argjson ex "$exempt_json" '
142
+ .[]
143
+ | select([(.labels // [])[].name] as $l
144
+ | ($l | index($s))
145
+ and (($l - ($l - $ex)) | length) == 0)
146
+ | .number')
147
+
148
+ # Mark: quiet for long enough, not exempt, not already stale.
149
+ items="$(fetch "$kind" "$stale_before")"
150
+ while read -r number; do
151
+ [ -n "$number" ] || continue
152
+ curl --fail-with-body -sS -o /dev/null -X POST "${AUTH[@]}" \
153
+ -H "Content-Type: application/json" \
154
+ "${BASE}/issues/${number}/labels" \
155
+ -d "$(jq -nc --arg l "$STALE_LABEL" '{labels: [$l]}')"
156
+ comment "$number" "$message"
157
+ echo " marked #${number} stale"
158
+ marked=$((marked + 1))
159
+ done < <(printf '%s' "$items" | jq -r \
160
+ --arg s "$STALE_LABEL" --argjson ex "$exempt_json" '
161
+ .[]
162
+ | select([(.labels // [])[].name] as $l
163
+ | ($l | index($s) | not)
164
+ and (($l - ($l - $ex)) | length) == 0)
165
+ | .number')
166
+ }
167
+
168
+ echo "Sweeping issues quiet since ${stale_before}"
169
+ sweep issues "$EXEMPT_ISSUE_LABELS" "$stale_issue_message"
170
+ echo "Sweeping pull requests quiet since ${stale_before}"
171
+ sweep pulls "$EXEMPT_PR_LABELS" "$stale_pr_message"
172
+
173
+ echo "Done: ${marked} marked stale, ${closed} closed."
174
+
175
+ unstale:
176
+ name: ♻️ Clear stale after activity
177
+ if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'
178
+ runs-on: @@RUNNER_YAML@@
179
+ env:
180
+ FORGEJO_API: ${{ github.api_url }}
181
+ FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182
+ REPO_FULL: ${{ github.repository }}
183
+ STALE_LABEL: "stale"
184
+ steps:
185
+ - name: 🧰 Make sure jq is available
186
+ run: |
187
+ set -euo pipefail
188
+ command -v jq >/dev/null 2>&1 || {
189
+ apt-get update -qq && apt-get install -y -qq jq
190
+ }
191
+
192
+ - name: ♻️ Remove the stale label after activity
193
+ run: |
194
+ set -euo pipefail
195
+ OWNER="${REPO_FULL%%/*}"
196
+ REPO="${REPO_FULL##*/}"
197
+ BASE="${FORGEJO_API}/repos/${OWNER}/${REPO}"
198
+ AUTH=(-H "Authorization: token ${FORGEJO_TOKEN}" -H "Accept: application/json")
199
+
200
+ # Defence in depth. Forgejo suppresses workflow events caused by its
201
+ # own automatic token, so the sweep's label and its accompanying
202
+ # comment should never arrive here. If that ever stopped holding,
203
+ # the sweep's comment would read as fresh activity and strip the
204
+ # label the sweep had just applied, leaving the workflow inert.
205
+ sender="$(jq -r '.sender.login // empty' "$GITHUB_EVENT_PATH")"
206
+ sender_id="$(jq -r '.sender.id // empty' "$GITHUB_EVENT_PATH")"
207
+
208
+ is_automation=false
209
+ # Forgejo's built-in Actions account is user -2.
210
+ if [ "$sender_id" = "-2" ]; then
211
+ is_automation=true
212
+ fi
213
+ case "$sender" in
214
+ forgejo-actions|gitea-actions|*'[bot]') is_automation=true ;;
215
+ esac
216
+
217
+ if [ "$is_automation" = true ]; then
218
+ echo "The event came from ${sender:-an automation account} rather than a person; leaving the labels alone."
219
+ exit 0
220
+ fi
221
+
222
+ # A maintainer is still allowed to apply the stale label manually.
223
+ # Labels/comments created by this workflow's automatic token do not
224
+ # trigger another workflow, so the scheduled sweep never clears its
225
+ # own label here.
226
+ action="$(jq -r '.action // empty' "$GITHUB_EVENT_PATH")"
227
+ event_label="$(jq -r '.label.name // empty' "$GITHUB_EVENT_PATH")"
228
+ if [ "$action" = "labeled" ] && [ "$event_label" = "$STALE_LABEL" ]; then
229
+ echo "The stale label was applied explicitly; leaving it in place."
230
+ exit 0
231
+ fi
232
+
233
+ number="$(jq -r \
234
+ '.issue.number // .pull_request.number // .number // empty' \
235
+ "$GITHUB_EVENT_PATH")"
236
+ if [ -z "$number" ]; then
237
+ echo "::warning::Could not determine the issue or pull request number from the event."
238
+ exit 0
239
+ fi
240
+
241
+ labels="$(curl --fail-with-body -sS "${AUTH[@]}" \
242
+ "${BASE}/issues/${number}/labels")"
243
+ stale_id="$(printf '%s' "$labels" | jq -r --arg s "$STALE_LABEL" \
244
+ '.[] | select(.name == $s) | .id' | head -n 1)"
245
+
246
+ if [ -z "$stale_id" ]; then
247
+ echo "#${number} is not marked stale."
248
+ exit 0
249
+ fi
250
+
251
+ # A pull request from a fork runs with a read-only token, which
252
+ # cannot remove labels. That is not the contributor's fault, so do
253
+ # not fail their pull request over it; a maintainer can remove the
254
+ # label by hand.
255
+ if ! curl --fail-with-body -sS -o /dev/null -X DELETE "${AUTH[@]}" \
256
+ "${BASE}/issues/${number}/labels/${stale_id}"; then
257
+ echo "::warning::Could not remove the stale label from #${number}; the token may be read-only, as it is for pull requests from forks."
258
+ exit 0
259
+ fi
260
+ echo "Removed the stale label from #${number} after new activity."
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "description": "Timing lives in .forgejo/workflows/renovate.yml. A schedule here as well would make a manual 'Run workflow' do nothing outside that window.",
4
+ "extends": [
5
+ "config:recommended",
6
+ ":semanticCommits"
7
+ ],
8
+ "labels": ["dependencies"],
9
+ "prConcurrentLimit": 5,
10
+ "timezone": "Etc/UTC",
11
+ "packageRules": [
12
+ {
13
+ "description": "One pull request a week for all Forgejo Actions bumps, rather than one per action.",
14
+ "matchManagers": ["github-actions"],
15
+ "groupName": "forgejo actions",
16
+ "semanticCommitType": "ci",
17
+ "addLabels": ["ci"]
18
+ },
19
+ {
20
+ "description": "Group non-breaking production updates once a real manifest exists.",
21
+ "matchDepTypes": ["dependencies", "require"],
22
+ "matchUpdateTypes": ["minor", "patch"],
23
+ "groupName": "production minor and patch"
24
+ },
25
+ {
26
+ "matchDepTypes": ["devDependencies"],
27
+ "groupName": "development dependencies",
28
+ "semanticCommitType": "chore"
29
+ }
30
+ ],
31
+ "osvVulnerabilityAlerts": true,
32
+ "vulnerabilityAlerts": {
33
+ "description": "Forgejo has no Dependabot alerts, so these settings apply to the OSV-sourced alerts enabled above.",
34
+ "labels": ["dependencies", "security"]
35
+ }
36
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "server_url": "https://git.galie.io",
3
+ "nested_namespaces": false,
4
+ "runner": "ubuntu-latest",
5
+ "codeowners_pattern": ".*",
6
+ "tiers": {
7
+ "regular": [
8
+ ".forgejo/CODEOWNERS",
9
+ ".forgejo/ISSUE_TEMPLATE/*",
10
+ ".forgejo/PULL_REQUEST_TEMPLATE.md",
11
+ ".forgejo/workflows/lint.yml",
12
+ ".forgejo/workflows/pre-commit.yml"
13
+ ],
14
+ "full": [
15
+ ".forgejo/labels.yml",
16
+ ".forgejo/scripts/*",
17
+ ".forgejo/workflows/labels.yml",
18
+ ".forgejo/workflows/pr-labels.yml",
19
+ ".forgejo/workflows/release.yml",
20
+ ".forgejo/workflows/renovate.yml",
21
+ ".forgejo/workflows/stale.yml",
22
+ "renovate.json"
23
+ ]
24
+ },
25
+ "context": {
26
+ "PLATFORM_NAME": "Forgejo",
27
+ "PLATFORM_DIR": ".forgejo",
28
+ "CI_FILE": ".forgejo/workflows/lint.yml",
29
+ "ISSUES_URL": "{REPO_URL}/issues",
30
+ "CHANGES_URL": "{REPO_URL}/pulls",
31
+ "CONTRIBUTORS_URL": "{REPO_URL}/activity/contributors",
32
+ "HISTORY_URL": "{REPO_URL}/commits/branch/{BRANCH_URL}",
33
+ "FILE_URL": "{REPO_URL}/src/branch/{BRANCH_URL}",
34
+ "CODEOWNERS_NOTE": "Forgejo matches paths using Go regular expressions; `.*` is the catch-all.",
35
+ "AUTOMATION_NOTE": "Workflows use full action URLs and the Forgejo API. GitHub-only actions and APIs do not apply.",
36
+ "SECURITY_CHANNEL": "Set a private reporting address below before publishing this project.",
37
+ "LABEL_NOTE": "Run Sync labels once from Actions after the first push. PR Labels requires these labels.",
38
+ "EXTRA_SETUP": "Review Renovate and its bot credentials in `.forgejo/SETUP.md`. Confirm a runner with the chosen label exists before requiring checks.",
39
+ "PRE_COMMIT_WORKFLOW_HOOKS": "\n - repo: https://github.com/rhysd/actionlint\n rev: 914e7df21a07ef503a81201c76d2b11c789d3fca # frozen: v1.7.12\n hooks:\n - id: actionlint\n files: ^\\.forgejo/workflows/.*\\.ya?ml$\n args:\n - -ignore\n - 'specifying action \"https://[^\"]+\" in invalid format'"
40
+ }
41
+ }
@@ -0,0 +1,2 @@
1
+ # @@CODEOWNERS_NOTE@@
2
+ @@CODEOWNERS_RULE@@
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: 🐛 Bug Report
3
+ description: Report a defect so that this project can be fixed
4
+ title: "bug: "
5
+ labels: ["bug"]
6
+ body:
7
+ - type: markdown
8
+ attributes:
9
+ value: |
10
+ Thanks for taking the time to file a report. The more precisely you can
11
+ describe the problem, the faster it can be reproduced and fixed.
12
+
13
+ - type: checkboxes
14
+ id: preflight
15
+ attributes:
16
+ label: Before you start
17
+ options:
18
+ - label: I searched the open and closed issues and this has not been reported yet.
19
+ required: true
20
+ - label: I am running the most recent version of this project.
21
+ required: true
22
+
23
+ - type: input
24
+ id: version
25
+ attributes:
26
+ label: Version
27
+ description: The release tag or commit SHA you are running.
28
+ placeholder: "v1.2.3, or 0a1b2c3"
29
+ validations:
30
+ required: true
31
+
32
+ - type: textarea
33
+ id: current
34
+ attributes:
35
+ label: Current behavior
36
+ description: What happens today? Describe how the bug manifests.
37
+ validations:
38
+ required: true
39
+
40
+ - type: textarea
41
+ id: expected
42
+ attributes:
43
+ label: Expected behavior
44
+ description: What did you expect to happen instead?
45
+ validations:
46
+ required: true
47
+
48
+ - type: textarea
49
+ id: steps
50
+ attributes:
51
+ label: Steps to reproduce
52
+ description: The exact sequence someone else can follow to see the same result.
53
+ value: |
54
+ 1.
55
+ 2.
56
+ 3.
57
+ validations:
58
+ required: true
59
+
60
+ - type: textarea
61
+ id: environment
62
+ attributes:
63
+ label: Environment
64
+ description: Operating system, runtime version, browser -- whatever is relevant here.
65
+ validations:
66
+ required: false
67
+
68
+ - type: textarea
69
+ id: logs
70
+ attributes:
71
+ label: Relevant logs, errors, or code
72
+ description: This is rendered as a code block automatically, so no backticks are needed.
73
+ render: shell
74
+ validations:
75
+ required: false
76
+
77
+ - type: textarea
78
+ id: context
79
+ attributes:
80
+ label: Anything else?
81
+ description: Related issues, suggested fixes, links to discussions elsewhere.
82
+ validations:
83
+ required: false
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: ✨ Feature Request
3
+ description: Suggest an idea for this project
4
+ title: "feat: "
5
+ labels: ["enhancement"]
6
+ body:
7
+ - type: checkboxes
8
+ id: preflight
9
+ attributes:
10
+ label: Before you start
11
+ options:
12
+ - label: I searched the open and closed issues and this has not been requested yet.
13
+ required: true
14
+
15
+ - type: textarea
16
+ id: problem
17
+ attributes:
18
+ label: What problem does this solve?
19
+ description: Describe the problem or limitation you are running into.
20
+ validations:
21
+ required: true
22
+
23
+ - type: textarea
24
+ id: solution
25
+ attributes:
26
+ label: Preferred solution
27
+ description: A clear description of what you would like to happen.
28
+ validations:
29
+ required: true
30
+
31
+ - type: textarea
32
+ id: alternatives
33
+ attributes:
34
+ label: Alternatives considered
35
+ description: Other approaches you looked at, and why they fall short.
36
+ validations:
37
+ required: false
38
+
39
+ - type: textarea
40
+ id: context
41
+ attributes:
42
+ label: Additional context
43
+ description: Use cases, example code, screenshots, links to prior art.
44
+ validations:
45
+ required: false
46
+
47
+ - type: dropdown
48
+ id: contribute
49
+ attributes:
50
+ label: Would you be willing to submit a pull request for this?
51
+ description: Help is available if you would like to try but are not sure where to start.
52
+ options:
53
+ - "Yes"
54
+ - "Yes, with guidance"
55
+ - "No"
56
+ validations:
57
+ required: true