diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index ba63be71..d09bd05f 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -30,33 +30,6 @@ jobs: with: path: "dist" - check_version: - if: github.ref == 'refs/heads/master' - runs-on: ubuntu-latest - container: - image: node:lts - needs: - - transpile - outputs: - version: ${{ steps.version_check.outputs.version }} - is_prerelease: ${{ steps.version_check.outputs.is_prerelease }} - npm_tag: ${{ steps.version_check.outputs.npm_tag }} - steps: - - uses: actions/checkout@v3.3.0 - - name: Get version and determine if prerelease - id: version_check - run: | - VERSION=$(node -p "require('./package.json').version") - echo "version=$VERSION" >> $GITHUB_OUTPUT - if echo "$VERSION" | grep -qE '\-'; then - TAG=$(echo "$VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/') - echo "is_prerelease=true" >> $GITHUB_OUTPUT - echo "npm_tag=$TAG" >> $GITHUB_OUTPUT - else - echo "is_prerelease=false" >> $GITHUB_OUTPUT - echo "npm_tag=latest" >> $GITHUB_OUTPUT - fi - publish_to_npm: if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest @@ -64,7 +37,6 @@ jobs: image: node:lts needs: - transpile - - check_version env: DIST_FOLDER: "/dist/artifact" steps: @@ -75,31 +47,25 @@ jobs: - run: cp package.json $DIST_FOLDER - run: cp README.md $DIST_FOLDER - run: npm install - - name: Publish the library (regular release) - if: needs.check_version.outputs.is_prerelease == 'false' - run: npm publish $DIST_FOLDER --provenance - - name: Publish the library (prerelease) - if: needs.check_version.outputs.is_prerelease == 'true' - run: npm publish $DIST_FOLDER --tag ${{ needs.check_version.outputs.npm_tag }} --provenance + - name: Publish the library. + run: npm publish $DIST_FOLDER create_release: if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest needs: - - check_version - publish_to_npm steps: - uses: actions/checkout@v3.3.0 + - name: Get version from package.json + id: version + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - name: Create tag and release run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git tag v${{ needs.check_version.outputs.version }} - git push origin v${{ needs.check_version.outputs.version }} - if [ "${{ needs.check_version.outputs.is_prerelease }}" = "true" ]; then - gh release create v${{ needs.check_version.outputs.version }} --generate-notes --prerelease - else - gh release create v${{ needs.check_version.outputs.version }} --generate-notes - fi + git tag v${{ steps.version.outputs.version }} + git push origin v${{ steps.version.outputs.version }} + gh release create v${{ steps.version.outputs.version }} --generate-notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}