diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7452c47..aa500f5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,7 +30,21 @@ jobs: run: pnpm lint - name: Build project run: pnpm run build + - name: Extract package version + id: extract_version + run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT + - name: Check if version matches tag + id: check_version + run: | + tag_name="${{ github.ref_name }}" + package_version="${{ steps.extract_version.outputs.version }}" + if [[ "$tag_name" == "$package_version" || "$tag_name" == *"$package_version-alpha"* || "$tag_name" == *"$package_version-beta"* || "$tag_name" == *"$package_version-canary"* ]]; then + echo "::set-output name=should_publish::true" + else + echo "::set-output name=should_publish::false" + fi - name: Publish package to NPM + if: steps.check_version.outputs.should_publish == 'true' run: | if [[ "${{ github.ref_name }}" == *-alpha* ]]; then pnpm publish --access public --tag alpha