name: Publish packages on: push: branches: ['**'] # any branch: stable from master, alphas from 10.0 or ad-hoc branches workflow_dispatch: inputs: package: description: 'Optional: publish only this package (e.g. @mantine/core)' required: false type: string permissions: {} concurrency: group: publish-packages cancel-in-progress: false jobs: prepare: if: >- github.event_name == 'workflow_dispatch' || startsWith(github.event.head_commit.message, '[release] Version') runs-on: ubuntu-latest permissions: contents: read outputs: version: ${{ steps.detect.outputs.version }} release_type: ${{ steps.detect.outputs.release_type }} steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: ref: ${{ github.sha }} - name: Enable Corepack run: corepack enable - name: Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: node-version-file: '.nvmrc' cache: 'yarn' cache-dependency-path: '**/yarn.lock' - name: Install dependencies run: yarn --frozen-lockfile - name: Detect release id: detect run: | VERSION=$(node -p "require('./package.json').version") RELEASE_TYPE=$(npx tsx scripts/release/print-release-type.ts) echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "release_type=$RELEASE_TYPE" >> "$GITHUB_OUTPUT" test: needs: prepare if: ${{ !inputs.package }} runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: ref: ${{ github.sha }} - name: Enable Corepack run: corepack enable - name: Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: node-version-file: '.nvmrc' cache: 'yarn' cache-dependency-path: '**/yarn.lock' - name: Install dependencies run: yarn --frozen-lockfile - name: Generate files for docs run: npm run setup - name: Build public packages run: npm run build all - name: Run tests run: npm test publish: needs: [prepare, test] if: >- always() && needs.prepare.result == 'success' && (needs.test.result == 'success' || needs.test.result == 'skipped') runs-on: ubuntu-latest environment: release permissions: contents: read id-token: write steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: ref: ${{ github.sha }} - name: Enable Corepack run: corepack enable - name: Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: node-version-file: '.nvmrc' cache: 'yarn' cache-dependency-path: '**/yarn.lock' - name: Upgrade npm for trusted publishing (needs >= 11.5.1) run: npm install -g npm@latest - name: Install dependencies run: yarn --frozen-lockfile - name: Build all packages run: npm run build all - name: Publish env: PACKAGE: ${{ inputs.package }} run: | if [ -n "$PACKAGE" ]; then npm run publish:ci -- --package "$PACKAGE" else npm run publish:ci fi docs: needs: [prepare, publish] if: >- needs.publish.result == 'success' && (needs.prepare.outputs.release_type == 'patch' || needs.prepare.outputs.release_type == 'minor_major') && !inputs.package runs-on: ubuntu-latest concurrency: group: github-pages cancel-in-progress: false environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} permissions: contents: read pages: write id-token: write steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: ref: ${{ github.sha }} - name: Enable Corepack run: corepack enable - name: Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: node-version-file: '.nvmrc' cache: 'yarn' cache-dependency-path: '**/yarn.lock' - name: Install dependencies run: yarn --frozen-lockfile - name: Build public packages run: npm run build all - name: Build docs site run: | npm run docs:sponsors npm run docs:build - name: Set custom domain run: echo "mantine.dev" > apps/mantine.dev/out/CNAME - name: Upload Pages artifact uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5 with: path: apps/mantine.dev/out - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 announce: needs: [prepare, publish] if: >- needs.publish.result == 'success' && (needs.prepare.outputs.release_type == 'patch' || needs.prepare.outputs.release_type == 'minor_major') && !inputs.package runs-on: ubuntu-latest permissions: contents: write issues: write steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: ref: ${{ github.sha }} fetch-depth: 0 - name: Enable Corepack run: corepack enable - name: Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: node-version-file: '.nvmrc' cache: 'yarn' cache-dependency-path: '**/yarn.lock' - name: Install dependencies run: yarn --frozen-lockfile - name: Generate patch changelog if: needs.prepare.outputs.release_type == 'patch' run: npx tsx scripts/release/generate-patch-notes.ts - name: Generate minor/major changelog if: needs.prepare.outputs.release_type == 'minor_major' run: | DASHED=$(node -e "console.log(require('./package.json').version.replace(/\\./g,'-'))") DOTTED=$(node -p "require('./package.json').version") npm run generate-changelog -- "$DASHED" cp ".changelog/$DOTTED.md" .changelog/release-notes.md - name: Create GitHub release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ needs.prepare.outputs.version }} run: | gh release create "$VERSION" --title "$VERSION" --target "$GITHUB_SHA" --notes-file .changelog/release-notes.md - name: Close issues fixed in this release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} VERSION: ${{ needs.prepare.outputs.version }} LABEL: ${{ needs.prepare.outputs.release_type == 'patch' && 'Fixed in patch' || 'Fixed in minor' }} run: | set -euo pipefail RELEASE_URL="https://github.com/$GH_REPO/releases/tag/$VERSION" NUMBERS=$(gh api --paginate -X GET "repos/$GH_REPO/issues" \ -f labels="$LABEL" -f state=open -f per_page=100 \ --jq '.[] | select(.pull_request == null) | .number') if [ -z "$NUMBERS" ]; then echo "No open issues labeled \"$LABEL\"" exit 0 fi for NUMBER in $NUMBERS; do echo "Closing #$NUMBER" gh issue close "$NUMBER" --comment "Fixed in [$VERSION]($RELEASE_URL)" done - name: Post to Discord if: needs.prepare.outputs.release_type == 'patch' env: DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} run: | CONTENT=$(cat .changelog/discord.md) jq -n --arg content "$CONTENT" '{content: $content}' \ | curl -sf -X POST -H "Content-Type: application/json" -d @- "$DISCORD_WEBHOOK_URL"