|
| 1 | +name: 'Release Website' |
| 2 | + |
| 3 | +# Pin the documentation website to a stable JSON Forms release and (re)deploy |
| 4 | +# it. This is intentionally separate from publish.yaml: a website failure must |
| 5 | +# never taint or block an already-published npm release, and the site also |
| 6 | +# needs to be redeployable on its own (docs, news, community changes) without |
| 7 | +# cutting a library release. |
| 8 | +# |
| 9 | +# Run manually after a stable release, passing the released version. It bumps |
| 10 | +# the website's @jsonforms/* dependencies to that exact version, verifies the |
| 11 | +# site still builds, pushes the bump to master, and triggers the Netlify build |
| 12 | +# hook so production is published against the latest stable release. |
| 13 | +# |
| 14 | +# The optional regenerate_docs flag rebuilds the typedoc API docs from the |
| 15 | +# current state of master (no tag checkout) and commits the refreshed |
| 16 | +# website/static/api along with the bump. Use it while master still matches |
| 17 | +# the released code, i.e. right after a stable release. |
| 18 | +on: |
| 19 | + workflow_dispatch: |
| 20 | + inputs: |
| 21 | + version: |
| 22 | + type: 'string' |
| 23 | + description: 'stable JSON Forms version to pin the website to (e.g. 3.9.0)' |
| 24 | + required: true |
| 25 | + skip_bump: |
| 26 | + type: 'boolean' |
| 27 | + description: 'mark to skip the dependency bump and only rebuild/redeploy the current website state' |
| 28 | + required: false |
| 29 | + default: false |
| 30 | + skip_deploy: |
| 31 | + type: 'boolean' |
| 32 | + description: 'mark to only bump and push, skipping the Netlify deploy trigger' |
| 33 | + required: false |
| 34 | + default: false |
| 35 | + regenerate_docs: |
| 36 | + type: 'boolean' |
| 37 | + description: 'mark to regenerate the API docs from the current repository state and commit them' |
| 38 | + required: false |
| 39 | + default: false |
| 40 | + |
| 41 | +jobs: |
| 42 | + release-website: |
| 43 | + permissions: |
| 44 | + contents: 'write' |
| 45 | + runs-on: 'ubuntu-latest' |
| 46 | + steps: |
| 47 | + - uses: 'actions/checkout@v4' |
| 48 | + with: |
| 49 | + ref: 'master' |
| 50 | + token: '${{ secrets.JSONFORMS_PUBLISH_PAT }}' |
| 51 | + |
| 52 | + - name: 'Configure Git Credentials' |
| 53 | + run: | |
| 54 | + git config user.name "jsonforms-publish[bot]" |
| 55 | + git config user.email "jsonforms-publish@eclipsesource.com" |
| 56 | +
|
| 57 | + - name: 'Setup node' |
| 58 | + uses: 'actions/setup-node@v4' |
| 59 | + with: |
| 60 | + node-version-file: 'website/.nvmrc' |
| 61 | + registry-url: 'https://registry.npmjs.org' |
| 62 | + |
| 63 | + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 64 | + if: github.event.inputs.regenerate_docs == 'true' |
| 65 | + name: 'Install pnpm' |
| 66 | + with: |
| 67 | + run_install: false |
| 68 | + |
| 69 | + # Regenerate the API docs from the current repository state. The |
| 70 | + # packages are built first because typedoc resolves cross-package types |
| 71 | + # from the built lib/ output (same order as ci.yaml). |
| 72 | + - name: 'Regenerate API docs' |
| 73 | + if: github.event.inputs.regenerate_docs == 'true' |
| 74 | + run: | |
| 75 | + pnpm i --frozen-lockfile |
| 76 | + pnpm run build |
| 77 | + pnpm run doc |
| 78 | + ./website/copy-docs.sh |
| 79 | +
|
| 80 | + # Ensure the released version is actually on npmjs before pinning to it. |
| 81 | + - name: 'Wait for npm propagation' |
| 82 | + if: github.event.inputs.skip_bump == 'false' |
| 83 | + run: | |
| 84 | + for i in $(seq 1 30); do |
| 85 | + if [ "$(npm view @jsonforms/core@${VERSION} version 2> /dev/null)" = "${VERSION}" ]; then |
| 86 | + exit 0 |
| 87 | + fi |
| 88 | + echo "@jsonforms/core@${VERSION} not yet available on npmjs, retrying..." |
| 89 | + sleep 20 |
| 90 | + done |
| 91 | + echo "@jsonforms/core@${VERSION} did not appear on npmjs in time" |
| 92 | + exit 1 |
| 93 | + env: |
| 94 | + VERSION: ${{ github.event.inputs.version }} |
| 95 | + |
| 96 | + - name: 'Bump @jsonforms/* to the released version' |
| 97 | + if: github.event.inputs.skip_bump == 'false' |
| 98 | + working-directory: 'website' |
| 99 | + run: | |
| 100 | + npm install --save-exact \ |
| 101 | + @jsonforms/core@${VERSION} \ |
| 102 | + @jsonforms/react@${VERSION} \ |
| 103 | + @jsonforms/material-renderers@${VERSION} \ |
| 104 | + @jsonforms/examples@${VERSION} |
| 105 | + env: |
| 106 | + VERSION: ${{ github.event.inputs.version }} |
| 107 | + |
| 108 | + # Install (in case the bump was skipped) and verify the site builds before |
| 109 | + # pushing or deploying, so we never publish a broken bump. |
| 110 | + - name: 'Install' |
| 111 | + if: github.event.inputs.skip_bump == 'true' |
| 112 | + working-directory: 'website' |
| 113 | + run: npm ci |
| 114 | + |
| 115 | + - name: 'Verify build' |
| 116 | + working-directory: 'website' |
| 117 | + run: npm run build:current |
| 118 | + |
| 119 | + - name: 'Commit and push' |
| 120 | + if: github.event.inputs.skip_bump == 'false' || github.event.inputs.regenerate_docs == 'true' |
| 121 | + run: | |
| 122 | + if [ "${SKIP_BUMP}" = "false" ]; then |
| 123 | + git add website/package.json website/package-lock.json |
| 124 | + fi |
| 125 | + if [ "${REGENERATE_DOCS}" = "true" ]; then |
| 126 | + git add website/static/api |
| 127 | + fi |
| 128 | + if git diff --cached --quiet; then |
| 129 | + echo "Website already up to date, nothing to commit." |
| 130 | + elif [ "${SKIP_BUMP}" = "false" ] && [ "${REGENERATE_DOCS}" = "true" ]; then |
| 131 | + git commit -m "docs: pin website to JSON Forms ${VERSION} and regenerate API docs" |
| 132 | + git push origin HEAD:master |
| 133 | + elif [ "${SKIP_BUMP}" = "false" ]; then |
| 134 | + git commit -m "docs: pin website to JSON Forms ${VERSION}" |
| 135 | + git push origin HEAD:master |
| 136 | + else |
| 137 | + git commit -m "docs: regenerate website API docs" |
| 138 | + git push origin HEAD:master |
| 139 | + fi |
| 140 | + env: |
| 141 | + VERSION: ${{ github.event.inputs.version }} |
| 142 | + SKIP_BUMP: ${{ github.event.inputs.skip_bump }} |
| 143 | + REGENERATE_DOCS: ${{ github.event.inputs.regenerate_docs }} |
| 144 | + |
| 145 | + # Trigger the production build on Netlify. Automatic Netlify deploys are |
| 146 | + # disabled, so this hook is what publishes the site. |
| 147 | + - name: 'Trigger website deploy' |
| 148 | + if: github.event.inputs.skip_deploy == 'false' |
| 149 | + run: curl -fsS -X POST -d '{}' "${{ secrets.NETLIFY_WEBSITE_BUILD_HOOK }}" |
0 commit comments