Skip to content

Commit

Permalink
fix ci missing branch name (#340) (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey authored Jun 23, 2023
1 parent 2832b8d commit 980a87b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
48 changes: 26 additions & 22 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 980a87b

Please sign in to comment.