Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get tag_branch_name in the workflow file #8

Merged
merged 11 commits into from
Nov 16, 2023
Merged
6 changes: 0 additions & 6 deletions .github/scripts/tag_ref.sh

This file was deleted.

37 changes: 22 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down