diff --git a/.changeset/commit.js b/.changeset/commit.js new file mode 100644 index 00000000..23e83c33 --- /dev/null +++ b/.changeset/commit.js @@ -0,0 +1,11 @@ +const getVersionMessage = async (releasePlan) => { + const publishableReleases = releasePlan.releases.filter( + (release) => release.type !== 'none', + ) + + const newVersion = publishableReleases[0].newVersion + + return `v${newVersion}` +} + +module.exports = { getVersionMessage } diff --git a/.changeset/config.json b/.changeset/config.json index d9624412..3e045e7f 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,7 +1,7 @@ { "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", - "changelog": "@changesets/cli/changelog", - "commit": false, + "changelog": false, + "commit": "./commit.js", "fixed": [], "linked": [], "access": "public", diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0889df8..a0c3843b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,9 @@ name: Release -on: - push: - branches: - - main +permissions: + contents: write -env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} +on: workflow_dispatch jobs: release: @@ -30,10 +27,10 @@ jobs: # https://github.com/changesets/action/issues/98#issuecomment-917292485 run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc - - name: Install Dependencies + - name: Install dependencies run: pnpm i - - name: Prepare for Release + - name: Prepare for release run: | pnpm run format pnpm run lint @@ -42,13 +39,22 @@ jobs: pnpm run build pnpm run publint - - name: Create Release Pull Request or Publish to npm - id: changesets - uses: changesets/action@v1 + - uses: actions/github-script@v7 + id: version_to_release with: - title: 'chore: next release' - publish: pnpm release - commit: 'release: publish' + result-encoding: string + script: | + const fs = require('fs'); + const packageJson = JSON.parse(fs.readFileSync('./packages/vite-plugin-checker/package.json', 'utf8')); + return packageJson.version; + + - name: Publish to NPM + run: | + git tag vite-plugin-checker@${{ steps.version_to_release.outputs.result }} + git push origin vite-plugin-checker@${{ steps.version_to_release.outputs.result }} + pnpm -r publish --no-git-checks + + - name: GitHub release + run: pnpx changelogithub env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}