Merge pull request #64 from ohakutsu/renovate/pnpm-8.x #27
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: | |
branches: | |
- 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 | |
with: | |
result-encoding: string | |
script: | | |
const response = await github.rest.repos.listTags({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const tags = response.data; | |
const existsTag = tags.map(tag => tag.name).includes(`v${process.env.PACKAGE_VERSION}`); | |
console.log(`existsTag: ${existsTag}`); | |
return existsTag.toString(); | |
release: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
needs: | |
- check | |
if: needs.check.outputs.exists-tag == 'false' | |
permissions: | |
contents: write | |
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 }} |