Skip to content

chore: add more details for some api errors (#219) #99

chore: add more details for some api errors (#219)

chore: add more details for some api errors (#219) #99

Workflow file for this run

---
name: Publish
on:
push:
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
permissions: {}
outputs:
VERSION_EXISTS: ${{ steps.check-version.outputs.VERSION_EXISTS }}
VERSION: ${{ steps.get-version.outputs.VERSION }}
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version-file: package.json
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Get version
id: get-version
shell: bash
run: |
set +e
VERSION=v$(jq -r '.version' < package.json)
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Check if version already exists
id: check-version
shell: bash
run: |
set +e
git rev-parse "${{ steps.get-version.outputs.VERSION }}" >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "VERSION_EXISTS=true" >> "$GITHUB_OUTPUT"
else
echo "VERSION_EXISTS=false" >> "$GITHUB_OUTPUT"
fi
publish:
runs-on: ubuntu-latest
environment: Production
permissions:
contents: write
needs:
- check
if: needs.check.outputs.VERSION_EXISTS == 'false'
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Build package
run: |
npm ci
npm run build
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish git release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }}