Fix create release pull request workflow #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release package | |
on: | |
push: | |
- main | |
permissions: | |
contents: read | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
exists-tag: ${{ steps.check-tag.outputs.result }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set package version | |
run: echo "PACKAGE_VERSION=$(cat package.json | jq -r '.version')" >> "$GITHUB_ENV" | |
- name: Check tag | |
uses: actions/github-script@v7 | |
id: check-tag | |
result-encoding: string | |
script: | | |
const tags = github.rest.repos.listTags({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const existsTag = tags.map(tag => tag.name).includes?(`v${process.env.PACKAGE_VERSION}`); | |
return existsTag.toString(); | |
release: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
needs: | |
- check | |
if: needs.check.outputs.exists-tag == 'false' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: "https://registry.npmjs.org" | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Set package version | |
run: echo "PACKAGE_VERSION=$(cat package.json | jq -r '.version')" >> "$GITHUB_ENV" | |
- uses: pkgdeps/git-tag-action@v2 | |
with: | |
version: "${{ env.PACKAGE_VERSION }}" | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
git_commit_sha: ${{ github.sha }} | |
git_tag_prefix: "v" | |
github_repo: ${{ github.repository }} |