diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 07fab62a..d19a04ba 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,28 +1,32 @@ name: NPM Publish on: - release: - types: [created] + release: + types: [created] jobs: - test: - uses: ./.github/workflows/node.js.yml - - publish-npm: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: https://registry.npmjs.org/ - - run: ./scripts/publish.sh - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - uses: softprops/action-gh-release@v1 - with: - files: | - bundle.js - bundle.min.js + test: + uses: ./.github/workflows/node.js.yml + publish-npm: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + - name: Extract branch from tag + id: branch-from-tag + run: | + branch=$(git branch --contains "${{ github.ref }}" --format="%(refname:lstrip=2)" | head -1) + echo "Branch from tag: $branch" + - run: ./scripts/publish.sh ${{ steps.branch-from-tag.outputs.branch }} + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} + - uses: softprops/action-gh-release@v1 + with: + files: | + bundle.js + bundle.min.js diff --git a/scripts/publish.sh b/scripts/publish.sh index 50ee8b9b..d368fe8c 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -6,9 +6,9 @@ npm run build PACKAGE_NAME=$(cat package.json | jq -r '.name') PUBLISH_VERSION=$(cat package.json | jq -r '.version') -echo publishing ${PACKAGE_NAME}@$PUBLISH_VERSION +echo "Publishing ${PACKAGE_NAME}@$PUBLISH_VERSION" -BRANCH=${GITHUB_REF##*/} +BRANCH=$1 TAG="" if [[ "$BRANCH" == "buildnet" ]]; then TAG="--tag buildnet"