|
| 1 | +name: First Package Release |
| 2 | + |
| 3 | +# Bootstrap workflow for brand-new npm packages. |
| 4 | +# |
| 5 | +# npm Trusted Publishing cannot be configured until a package already exists on |
| 6 | +# the registry. This manual workflow handles that one-time gap by using a short |
| 7 | +# lived NPM_TOKEN secret to publish only public workspace packages whose package |
| 8 | +# name is not on npm yet. It skips packages that already exist, even when the |
| 9 | +# local version has not been published. |
| 10 | +# |
| 11 | +# This runs through changesets/action so successful first publishes get the |
| 12 | +# same tag and GitHub Release behavior as the normal Release workflow. It must |
| 13 | +# run on a versioned checkout with no pending changeset files; otherwise |
| 14 | +# changesets/action would create/update a release PR instead of publishing. |
| 15 | +# Newly published packages must already have a CHANGELOG.md entry for their |
| 16 | +# current version, because changesets/action uses that entry as the GitHub |
| 17 | +# Release body. |
| 18 | +# |
| 19 | +# Before running: |
| 20 | +# - Create a temporary npm granular access token with read/write access to the |
| 21 | +# relevant scope, a short expiration, and 2FA bypass for automation. |
| 22 | +# Command-line equivalent: |
| 23 | +# npm token create \ |
| 24 | +# --name "first-package-release" \ |
| 25 | +# --expires 1 \ |
| 26 | +# --scopes @fujocoded \ |
| 27 | +# --packages-and-scopes-permission read-write \ |
| 28 | +# --bypass-2fa |
| 29 | +# - Add it to this repository's Actions secrets as NPM_TOKEN. |
| 30 | +# Command-line equivalent: |
| 31 | +# gh secret set NPM_TOKEN \ |
| 32 | +# --repo FujoWebDev/fujocoded-plugins \ |
| 33 | +# --body "<temporary-npm-token>" |
| 34 | +# - Run this workflow manually. |
| 35 | +# Command-line equivalent: |
| 36 | +# gh workflow run first-release.yaml \ |
| 37 | +# --repo FujoWebDev/fujocoded-plugins \ |
| 38 | +# --ref <branch-or-tag> |
| 39 | +# |
| 40 | +# After a successful first release: |
| 41 | +# - Configure Trusted Publishing for each newly published package, using this |
| 42 | +# repository and the normal release.yaml workflow file. |
| 43 | +# Command-line equivalent: |
| 44 | +# npm trust github <package-name> \ |
| 45 | +# --repo FujoWebDev/fujocoded-plugins \ |
| 46 | +# --file release.yaml \ |
| 47 | +# --allow-publish |
| 48 | +# - Delete the NPM_TOKEN repository secret and revoke the npm token. |
| 49 | +# Command-line equivalent: |
| 50 | +# gh secret delete NPM_TOKEN \ |
| 51 | +# --repo FujoWebDev/fujocoded-plugins |
| 52 | +# npm token revoke <token-id-or-token> |
| 53 | +# - Use the normal Release workflow for future package versions. |
| 54 | + |
| 55 | +on: |
| 56 | + workflow_dispatch: |
| 57 | + |
| 58 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 59 | + |
| 60 | +permissions: |
| 61 | + id-token: write |
| 62 | + contents: write |
| 63 | + |
| 64 | +jobs: |
| 65 | + first-release: |
| 66 | + name: First Package Release |
| 67 | + runs-on: ubuntu-latest |
| 68 | + steps: |
| 69 | + - name: Checkout |
| 70 | + uses: actions/checkout@v6 |
| 71 | + |
| 72 | + - name: Setup Node.js |
| 73 | + uses: actions/setup-node@v6 |
| 74 | + with: |
| 75 | + node-version: 24 |
| 76 | + registry-url: "https://registry.npmjs.org" |
| 77 | + |
| 78 | + - name: Install dependencies |
| 79 | + run: npm ci |
| 80 | + |
| 81 | + - name: Refuse pending changesets |
| 82 | + run: | |
| 83 | + if find .changeset -maxdepth 1 -type f -name '*.md' ! -name README.md | grep -q .; then |
| 84 | + echo "::error::First Package Release must run on a versioned checkout with no pending changeset files." |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | +
|
| 88 | + - name: Build |
| 89 | + run: npm run build |
| 90 | + |
| 91 | + - name: Publish first-release packages |
| 92 | + uses: changesets/action@v1 |
| 93 | + with: |
| 94 | + publish: node .github/workflows/scripts/first-release-publish.mjs |
| 95 | + createGithubReleases: true |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments