Skip to content

Merge pull request #2235 from Ericlm/main #1911

Merge pull request #2235 from Ericlm/main

Merge pull request #2235 from Ericlm/main #1911

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Optional: Custom tag for canary release'
required: false
type: string
push:
branches: ["main", "alpha", "beta", "rc"]
paths:
- ".changeset/**"
- "packages/**"
permissions:
actions: write
contents: write
id-token: write
packages: write
pull-requests: write
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
name: Release
if: github.repository_owner == 'kubb-labs'
timeout-minutes: 15
runs-on: ubuntu-latest
outputs:
published_packages: ${{ steps.changesets.outputs.publishedPackages }}
published: ${{ steps.changesets.outputs.published }}
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Tools
uses: kubb-labs/config/.github/setup@main
- name: Build
run: pnpm run build
- name: Test
run: pnpm run test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Publish
id: changesets
uses: changesets/action@v1
if: ${{ github.event.inputs.tag == '' }}
with:
publish: pnpm release
commit: "ci(changesets): version packages"
setupGitUser: false
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish ${{ inputs.tag || 'canary' }}
id: canary
if: steps.changesets.outputs.published != 'true'
run: |
git checkout main
pnpm version:canary
pnpm release:canary --tag ${{ inputs.tag || 'canary' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
notify:
name: Send Discord Notification
if: needs.release.outputs.published == 'true'
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Send a discord notification
uses: actions/github-script@v7
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
PUBLISHED_PACKAGES: ${{ needs.release.outputs.published_packages }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const publishedPackages = JSON.parse(process.env.PUBLISHED_PACKAGES || '[]');
const corePackage = publishedPackages.find(pkg => pkg.name === '@kubb/core');
const version = corePackage?.version || '';
const versionSlug = version.replace(/\./g, '-');
const docsUrl = version ? `https://www.kubb.dev/changelog#_${versionSlug}` : 'https://www.kubb.dev/changelog';
fetch(process.env.DISCORD_WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: `A new release is available 🎉. \n [Read the changelog](https://github.com/kubb-labs/kubb/releases) \n [View docs changelog](${docsUrl})`
}),
})
.then((res) => {
console.log('Sent discord notification', res)
})
.catch((err) => {
console.error('Error sending discord notification', err)
})
comment:
name: Comment on related issues and pull requests
if: needs.release.outputs.published == 'true'
needs: [release]
runs-on: ubuntu-latest
permissions:
issues: write # enable commenting on released issues
pull-requests: write # enable commenting on released pull requests
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
# IMPORTANT: if you make changes here, also make them in release-comment-manual.yml
- name: Comment on related issues and pull requests
uses: remix-run/release-comment-action@v0.5.1
with:
DIRECTORY_TO_CHECK: "./packages"
PACKAGE_NAME: "@kubb/core"
ISSUE_LABELS_TO_KEEP_OPEN: "🗺 Roadmap"