Skip to content

Merge pull request #15 from CloudCannon/fix/sdk-0.0.7 #7

Merge pull request #15 from CloudCannon/fix/sdk-0.0.7

Merge pull request #15 from CloudCannon/fix/sdk-0.0.7 #7

Workflow file for this run

name: Release
on:
push:
tags:
- v*
jobs:
test:
uses: ./.github/workflows/test.yml
publish-npm-package:
runs-on: ubuntu-latest
needs: test
outputs:
npm_tag: ${{ steps.npm_tag.outputs.value }}
permissions:
id-token: write
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Get tag
id: npm_tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
# e.g.: x.y.z -> latest, x.y.z-rc.1 -> rc
TAG=$([[ "$VERSION" == *-* ]] && echo "${VERSION#*-}" | cut -d. -f1 || echo latest)
echo "value=$TAG" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v6
with:
cache: npm
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
- name: Set version in package.json
run: npm --no-git-tag-version version "${GITHUB_REF_NAME#v}"
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Publish package on npm
run: npm publish --tag ${{ steps.npm_tag.outputs.value }}
- uses: actions/setup-node@v6
with:
registry-url: https://npm.pkg.github.com
- name: Publish package on GitHub
run: npm publish --tag ${{ steps.npm_tag.outputs.value }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-github-release:
runs-on: ubuntu-latest
needs: publish-npm-package
permissions:
contents: write
steps:
- name: Create release
run: |
if [ "${{ needs.publish-npm-package.outputs.npm_tag }}" = "latest" ]; then
gh release create ${{ github.ref_name }} --generate-notes --repo ${{ github.repository }}
else
gh release create ${{ github.ref_name }} --generate-notes --prerelease --repo ${{ github.repository }}
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}