diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1282c4f..39ad7e6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,6 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@main - uses: yanhao98/composite-actions/setup-node-environment@main - run: pnpm test - name: "Memory test" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 81ed9e4..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Publish Package - -permissions: - id-token: write - # contents: write - -on: - push: - tags: - - v* - -jobs: - publish-npm: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install pnpm - uses: pnpm/action-setup@v3 - with: - version: 8 - - - name: Use Node.js v18 - uses: actions/setup-node@v4 - with: - node-version: 18 - registry-url: https://registry.npmjs.org/ - cache: pnpm - - - run: pnpm install --frozen-lockfile - - - name: Set publish args if beta version - run: | - if grep -q "-beta" package.json; then - echo "PUBLISH_ARGS=--tag beta" >> $GITHUB_ENV - echo "This is a beta version 🅱️" - fi - - - name: Publish to npm - run: npm publish --access public $PUBLISH_ARGS - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - NPM_CONFIG_PROVENANCE: true diff --git a/.github/workflows/release-and-publish.yaml b/.github/workflows/release-and-publish.yaml new file mode 100644 index 0000000..5b59b99 --- /dev/null +++ b/.github/workflows/release-and-publish.yaml @@ -0,0 +1,19 @@ +name: Release and publish +on: + push: + branches: + - main +jobs: + release: + runs-on: ubuntu-latest + permissions: # Job-level permissions configuration starts here + id-token: write # npm provenance requires this permission + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + steps: + - uses: yanhao98/composite-actions/setup-node-environment@main + - uses: yanhao98/semantic-release-action@main + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.releaserc.yaml b/.releaserc.yaml new file mode 100644 index 0000000..f086a9f --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,20 @@ +--- +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - "@semantic-release/changelog" + # ############################# + # https://github.com/semantic-release/npm?tab=readme-ov-file#environment-variables + # ############################# + - - "@semantic-release/npm" + # [provenance](https://docs.npmjs.com/generating-provenance-statements#using-third-party-package-publishing-tools) + - npmPublish: true + # ############################# + # https://github.com/semantic-release/github?tab=readme-ov-file#configuration + # ############################# + - "@semantic-release/github" + - - "@semantic-release/git" + - message: |- + chore(release): ${nextRelease.version} [skip ci] + + ${nextRelease.notes} diff --git a/package.json b/package.json index 1242e06..a9982f5 100644 --- a/package.json +++ b/package.json @@ -40,5 +40,8 @@ "tsup": "^8.3.5", "typescript": "^5.6.3", "vitest": "^2.1.3" - } + }, + "publishConfig": { + "provenance": true + } }