diff --git a/.github/scripts/tag_ref.sh b/.github/scripts/tag_ref.sh deleted file mode 100644 index fbf1c1f..0000000 --- a/.github/scripts/tag_ref.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -raw=$(git branch -r --contains $1) -branch=${raw##*/} || "" - -echo "TAG_BRANCH=$branch" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 56f2226..7b037b1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,13 +21,23 @@ jobs: prepare: runs-on: ubuntu-latest outputs: - TAG_BRANCH: ${{ env.TAG_BRANCH }} + TAG_BRANCH: ${{ env.TAG_BRANCH_NAME }} + TAGGED: ${{ env.TAGGED }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: get-tag-branch - run: bash .github/scripts/tag_ref.sh ${{ github.ref }} + + - id: prepare_env + run: | + echo "TAGGED=${{ startsWith(github.ref, 'refs/tags/v') }}" >> $GITHUB_ENV + + SHORT_SHA=$(git rev-parse --short HEAD) + + RAW=$(git branch -r --contains $SHORT_SHA) + TAG_BRANCH_NAME="${RAW##*/}" + echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV + - run: echo "${{ toJSON(env) }}" test: @@ -56,28 +66,23 @@ jobs: **/node_modules key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: install dependencies - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: install - - name: build package - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: build - - name: build types - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: tsc - - name: test types - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: tsd - - name: test functionality - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: test @@ -90,16 +95,18 @@ jobs: name: Publish to npmjs runs-on: ubuntu-latest needs: [prepare, test] - if: ${{ needs.prepare.outputs.TAG_BRANCH == 'main' && startsWith(github.ref, 'refs/tags/v') }} + if: ${{ needs.prepare.outputs.TAG_BRANCH == 'main' && needs.prepare.outputs.TAGGED == 'true' }} steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: "16.x" + node-version: "18.x" + - uses: actions/download-artifact@v3 with: name: lib path: lib + - uses: heinrichreimer/github-changelog-generator-action@v2.3 with: token: ${{ secrets.GITHUB_TOKEN }}