| 1 | # Publishes g1t's Claude Code plugin marketplace to flagon-io/g1t-plugins |
| 2 | # on g1t.sh, so people add it without cloning this repository: |
| 3 | # |
| 4 | # claude plugin marketplace add https://g1t.sh/flagon-io/g1t-plugins.git |
| 5 | # claude plugin install g1t@g1t |
| 6 | # |
| 7 | # This repository is the plugin's source: .claude-plugin/marketplace.json |
| 8 | # and plugins/claude-code/. scripts/plugins-release.mjs builds the published |
| 9 | # tree from them (the manifest, the plugin without its tests, a README and |
| 10 | # the license, the plugin's source rewritten to ./plugins/g1t), checks it |
| 11 | # holds nothing else and nothing secret, and commits it to g1t-plugins' |
| 12 | # main only when it changed; each new version is tagged g1t--v<version>, |
| 13 | # as `claude plugin tag` would. A change to the plugin's files without a |
| 14 | # new version stops the run, as Claude Code updates installed plugins only |
| 15 | # when the version changes. |
| 16 | # |
| 17 | # Runs on a push to main that changes the plugin, its manifest or the |
| 18 | # script, and by hand. |
| 19 | # |
| 20 | # Needs the repository secret PLUGINS_PUBLISH_TOKEN: a workspace token of |
| 21 | # flagon-io (g1t.sh/flagon-io/-/tokens, made by an owner; it acts as the |
| 22 | # workspace, not a person), select repositories: g1t-plugins only, with |
| 23 | # Code: read and write (code:write) and nothing else. g1t-plugins must |
| 24 | # exist, public; this never creates it. The published tree has no workflow |
| 25 | # files, so the token needs no workflow_files:write. The job's own token |
| 26 | # reaches this repository only, and only to read it. |
| 27 | name: Plugins release |
| 28 | |
| 29 | on: |
| 30 | push: |
| 31 | branches: [main] |
| 32 | paths: |
| 33 | - .claude-plugin/** |
| 34 | - plugins/claude-code/** |
| 35 | - scripts/plugins-release.mjs |
| 36 | - LICENSE |
| 37 | workflow_dispatch: |
| 38 | |
| 39 | permissions: |
| 40 | contents: read |
| 41 | |
| 42 | concurrency: |
| 43 | group: plugins-release |
| 44 | cancel-in-progress: false |
| 45 | |
| 46 | jobs: |
| 47 | publish: |
| 48 | name: Publish flagon-io/g1t-plugins |
| 49 | runs-on: ubuntu-latest |
| 50 | timeout-minutes: 10 |
| 51 | steps: |
| 52 | - uses: actions/checkout@v5 |
| 53 | with: |
| 54 | # Without the job's own token in git's config: it would go with |
| 55 | # the push to g1t-plugins beside the publish token, and be refused. |
| 56 | persist-credentials: false |
| 57 | - name: The plugin's tests |
| 58 | run: | |
| 59 | node --test plugins/claude-code/test/hooks.test.mjs |
| 60 | node --test scripts/plugins-release.test.mjs |
| 61 | - name: Publish |
| 62 | env: |
| 63 | PLUGINS_PUBLISH_TOKEN: ${{ secrets.PLUGINS_PUBLISH_TOKEN }} |
| 64 | G1T_PLUGINS_REMOTE: ${{ github.server_url }}/flagon-io/g1t-plugins.git |
| 65 | G1T_SOURCE_COMMIT: ${{ github.sha }} |
| 66 | run: | |
| 67 | if [ -z "${PLUGINS_PUBLISH_TOKEN}" ]; then |
| 68 | echo "::error::Set the repository secret PLUGINS_PUBLISH_TOKEN (this workflow's header says what it needs)." |
| 69 | exit 1 |
| 70 | fi |
| 71 | echo "::add-mask::${PLUGINS_PUBLISH_TOKEN}" |
| 72 | node scripts/plugins-release.mjs publish |