|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump: |
| 7 | + description: "patch: bug fixes (0.1.0→0.1.1) | minor: new features (0.1.0→0.2.0) | major: breaking changes (0.1.0→1.0.0)" |
| 8 | + type: choice |
| 9 | + default: "patch" |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + release_core: |
| 15 | + description: "Release @mondaycom/hatcha-core" |
| 16 | + type: boolean |
| 17 | + default: true |
| 18 | + release_server: |
| 19 | + description: "Release @mondaycom/hatcha-server" |
| 20 | + type: boolean |
| 21 | + default: true |
| 22 | + release_react: |
| 23 | + description: "Release @mondaycom/hatcha-react" |
| 24 | + type: boolean |
| 25 | + default: true |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: write |
| 29 | + id-token: write |
| 30 | + |
| 31 | +concurrency: |
| 32 | + group: release |
| 33 | + cancel-in-progress: false |
| 34 | + |
| 35 | +jobs: |
| 36 | + release: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + - uses: pnpm/action-setup@v4 |
| 44 | + |
| 45 | + - uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version-file: '.nvmrc' |
| 48 | + cache: pnpm |
| 49 | + registry-url: "https://registry.npmjs.org" |
| 50 | + |
| 51 | + - run: pnpm install --frozen-lockfile |
| 52 | + |
| 53 | + - name: Validate selection |
| 54 | + env: |
| 55 | + RELEASE_CORE: ${{ inputs.release_core }} |
| 56 | + RELEASE_SERVER: ${{ inputs.release_server }} |
| 57 | + RELEASE_REACT: ${{ inputs.release_react }} |
| 58 | + run: | |
| 59 | + if [[ "$RELEASE_CORE" != "true" && \ |
| 60 | + "$RELEASE_SERVER" != "true" && \ |
| 61 | + "$RELEASE_REACT" != "true" ]]; then |
| 62 | + echo "::error::No packages selected for release" |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + if [[ "$RELEASE_CORE" != "true" ]]; then |
| 66 | + if [[ "$RELEASE_SERVER" == "true" || "$RELEASE_REACT" == "true" ]]; then |
| 67 | + echo "::error::Cannot release server/react without core. Core must be included to ensure dependency versions are correct." |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Bump versions |
| 73 | + id: versions |
| 74 | + env: |
| 75 | + BUMP: ${{ inputs.bump }} |
| 76 | + RELEASE_CORE: ${{ inputs.release_core }} |
| 77 | + RELEASE_SERVER: ${{ inputs.release_server }} |
| 78 | + RELEASE_REACT: ${{ inputs.release_react }} |
| 79 | + run: | |
| 80 | + if [[ "$RELEASE_CORE" == "true" ]]; then |
| 81 | + cd packages/core |
| 82 | + NEW_VERSION=$(npm version "$BUMP" --no-git-tag-version) |
| 83 | + echo "core_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" |
| 84 | + echo "Core bumped to ${NEW_VERSION}" |
| 85 | + cd ../.. |
| 86 | + fi |
| 87 | +
|
| 88 | + if [[ "$RELEASE_SERVER" == "true" ]]; then |
| 89 | + cd packages/server |
| 90 | + NEW_VERSION=$(npm version "$BUMP" --no-git-tag-version) |
| 91 | + echo "server_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" |
| 92 | + echo "Server bumped to ${NEW_VERSION}" |
| 93 | + cd ../.. |
| 94 | + fi |
| 95 | +
|
| 96 | + if [[ "$RELEASE_REACT" == "true" ]]; then |
| 97 | + cd packages/react |
| 98 | + NEW_VERSION=$(npm version "$BUMP" --no-git-tag-version) |
| 99 | + echo "react_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" |
| 100 | + echo "React bumped to ${NEW_VERSION}" |
| 101 | + cd ../.. |
| 102 | + fi |
| 103 | +
|
| 104 | + - name: Update lockfile |
| 105 | + run: pnpm install --no-frozen-lockfile |
| 106 | + |
| 107 | + - name: Build |
| 108 | + run: pnpm build |
| 109 | + |
| 110 | + - name: Test |
| 111 | + run: pnpm test |
| 112 | + |
| 113 | + - name: Typecheck |
| 114 | + run: pnpm typecheck |
| 115 | + |
| 116 | + - name: Publish core |
| 117 | + if: inputs.release_core |
| 118 | + run: pnpm --filter @mondaycom/hatcha-core publish --no-git-checks --provenance |
| 119 | + env: |
| 120 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 121 | + |
| 122 | + - name: Publish server |
| 123 | + if: inputs.release_server |
| 124 | + run: pnpm --filter @mondaycom/hatcha-server publish --no-git-checks --provenance |
| 125 | + env: |
| 126 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 127 | + |
| 128 | + - name: Publish react |
| 129 | + if: inputs.release_react |
| 130 | + run: pnpm --filter @mondaycom/hatcha-react publish --no-git-checks --provenance |
| 131 | + env: |
| 132 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 133 | + |
| 134 | + - name: Commit and tag |
| 135 | + env: |
| 136 | + CORE_VERSION: ${{ steps.versions.outputs.core_version }} |
| 137 | + SERVER_VERSION: ${{ steps.versions.outputs.server_version }} |
| 138 | + REACT_VERSION: ${{ steps.versions.outputs.react_version }} |
| 139 | + run: | |
| 140 | + git config user.name "github-actions[bot]" |
| 141 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 142 | +
|
| 143 | + git add packages/*/package.json pnpm-lock.yaml |
| 144 | +
|
| 145 | + MSG="release [skip ci]:" |
| 146 | + TAGS=() |
| 147 | +
|
| 148 | + if [[ -n "$CORE_VERSION" ]]; then |
| 149 | + MSG="${MSG} core@${CORE_VERSION}" |
| 150 | + TAGS+=("@mondaycom/hatcha-core@${CORE_VERSION}") |
| 151 | + fi |
| 152 | + if [[ -n "$SERVER_VERSION" ]]; then |
| 153 | + MSG="${MSG} server@${SERVER_VERSION}" |
| 154 | + TAGS+=("@mondaycom/hatcha-server@${SERVER_VERSION}") |
| 155 | + fi |
| 156 | + if [[ -n "$REACT_VERSION" ]]; then |
| 157 | + MSG="${MSG} react@${REACT_VERSION}" |
| 158 | + TAGS+=("@mondaycom/hatcha-react@${REACT_VERSION}") |
| 159 | + fi |
| 160 | +
|
| 161 | + git commit -m "${MSG}" |
| 162 | +
|
| 163 | + for TAG in "${TAGS[@]}"; do |
| 164 | + git tag "${TAG}" |
| 165 | + done |
| 166 | +
|
| 167 | + git push origin HEAD --tags --atomic |
| 168 | +
|
| 169 | + - name: Create GitHub Releases |
| 170 | + env: |
| 171 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 172 | + CORE_VERSION: ${{ steps.versions.outputs.core_version }} |
| 173 | + SERVER_VERSION: ${{ steps.versions.outputs.server_version }} |
| 174 | + REACT_VERSION: ${{ steps.versions.outputs.react_version }} |
| 175 | + run: | |
| 176 | + LAST_TAG="" |
| 177 | +
|
| 178 | + if [[ -n "$CORE_VERSION" ]]; then |
| 179 | + LAST_TAG="@mondaycom/hatcha-core@${CORE_VERSION}" |
| 180 | + gh release create "$LAST_TAG" \ |
| 181 | + --title "hatcha-core ${CORE_VERSION}" \ |
| 182 | + --generate-notes \ |
| 183 | + --latest=false |
| 184 | + fi |
| 185 | + if [[ -n "$SERVER_VERSION" ]]; then |
| 186 | + LAST_TAG="@mondaycom/hatcha-server@${SERVER_VERSION}" |
| 187 | + gh release create "$LAST_TAG" \ |
| 188 | + --title "hatcha-server ${SERVER_VERSION}" \ |
| 189 | + --generate-notes \ |
| 190 | + --latest=false |
| 191 | + fi |
| 192 | + if [[ -n "$REACT_VERSION" ]]; then |
| 193 | + LAST_TAG="@mondaycom/hatcha-react@${REACT_VERSION}" |
| 194 | + gh release create "$LAST_TAG" \ |
| 195 | + --title "hatcha-react ${REACT_VERSION}" \ |
| 196 | + --generate-notes \ |
| 197 | + --latest=false |
| 198 | + fi |
| 199 | +
|
| 200 | + # Mark the last release as "Latest" |
| 201 | + if [[ -n "$LAST_TAG" ]]; then |
| 202 | + gh release edit "$LAST_TAG" --latest |
| 203 | + fi |
| 204 | +
|
| 205 | + - name: Summary |
| 206 | + env: |
| 207 | + CORE_VERSION: ${{ steps.versions.outputs.core_version }} |
| 208 | + SERVER_VERSION: ${{ steps.versions.outputs.server_version }} |
| 209 | + REACT_VERSION: ${{ steps.versions.outputs.react_version }} |
| 210 | + run: | |
| 211 | + echo "## Release Summary" >> "$GITHUB_STEP_SUMMARY" |
| 212 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 213 | + echo "| Package | Version |" >> "$GITHUB_STEP_SUMMARY" |
| 214 | + echo "|---------|---------|" >> "$GITHUB_STEP_SUMMARY" |
| 215 | + if [[ -n "$CORE_VERSION" ]]; then |
| 216 | + echo "| @mondaycom/hatcha-core | ${CORE_VERSION} |" >> "$GITHUB_STEP_SUMMARY" |
| 217 | + fi |
| 218 | + if [[ -n "$SERVER_VERSION" ]]; then |
| 219 | + echo "| @mondaycom/hatcha-server | ${SERVER_VERSION} |" >> "$GITHUB_STEP_SUMMARY" |
| 220 | + fi |
| 221 | + if [[ -n "$REACT_VERSION" ]]; then |
| 222 | + echo "| @mondaycom/hatcha-react | ${REACT_VERSION} |" >> "$GITHUB_STEP_SUMMARY" |
| 223 | + fi |
0 commit comments