From 1f7e5c999daf0487a6b76383961fffdee316b595 Mon Sep 17 00:00:00 2001 From: Daniel Sarlo Date: Sat, 28 Oct 2023 19:37:12 -0400 Subject: [PATCH 1/3] Setup github actions to publish only on release tags --- .github/workflows/build.yml | 50 ----------------------------- .github/workflows/pull_requests.yml | 20 ++++++++++++ .github/workflows/release_tags.yml | 46 ++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/pull_requests.yml create mode 100644 .github/workflows/release_tags.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d5f9c73..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - name: Test and Build - steps: - - uses: actions/checkout@v2 - - name: Use Node.js 18.x - uses: actions/setup-node@v1 - with: - node-version: 18.x - - name: install, lint, test, build - run: | - DEBUG=true yarn install --frozen-lockfile - yarn run lint - yarn test - yarn build - - publish: - name: Publish - runs-on: ubuntu-latest - needs: [test] - if: github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v2 - - name: Use Node.js 18.x - uses: actions/setup-node@v1 - with: - node-version: 18.x - - name: install - run: yarn install --frozen-lockfile - - - name: package-version - run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV - - - name: package-version-to-git-tag - uses: pkgdeps/git-tag-action@v2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - github_repo: ${{ github.repository }} - version: ${{ env.PACKAGE_VERSION }} - git_commit_sha: ${{ github.sha }} - git_tag_prefix: "v" - - - uses: JS-DevTools/npm-publish@v1 - with: - token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml new file mode 100644 index 0000000..0c5cd44 --- /dev/null +++ b/.github/workflows/pull_requests.yml @@ -0,0 +1,20 @@ +name: pull_requests + +on: [pull_request] + +jobs: + test: + runs-on: ubuntu-latest + name: Test and Build + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 18.x + uses: actions/setup-node@v1 + with: + node-version: 18.x + - name: install, lint, test, build + run: | + DEBUG=true yarn install --frozen-lockfile + yarn run lint + yarn test + yarn build \ No newline at end of file diff --git a/.github/workflows/release_tags.yml b/.github/workflows/release_tags.yml new file mode 100644 index 0000000..3171d6b --- /dev/null +++ b/.github/workflows/release_tags.yml @@ -0,0 +1,46 @@ +name: release_tags + +on: + push: + tags: + - 'v*.*.*' + +jobs: + test: + runs-on: ubuntu-latest + name: Test and Build + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: install, lint, test, build + run: | + DEBUG=true yarn install --frozen-lockfile + yarn run lint + yarn test + yarn build + + publish: + name: Publish + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: install + run: yarn install --frozen-lockfile + + - name: git-tag-name + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: git-tag-to-package-version + run: npm version ${{ env.RELEASE_VERSION }} + + - uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} From f1a26b4a22a43b6a381d8a44c5d401a992b0c2db Mon Sep 17 00:00:00 2001 From: Daniel Sarlo Date: Sat, 28 Oct 2023 19:38:47 -0400 Subject: [PATCH 2/3] Removed git tag when using npm version --- .github/workflows/release_tags.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_tags.yml b/.github/workflows/release_tags.yml index 3171d6b..3448513 100644 --- a/.github/workflows/release_tags.yml +++ b/.github/workflows/release_tags.yml @@ -39,7 +39,7 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: git-tag-to-package-version - run: npm version ${{ env.RELEASE_VERSION }} + run: npm version ${{ env.RELEASE_VERSION }} --no-git-tag-version - uses: JS-DevTools/npm-publish@v3 with: From 0473f58122a3329f4baed2bcccd86f31127ba997 Mon Sep 17 00:00:00 2001 From: Daniel Sarlo Date: Sat, 28 Oct 2023 19:45:57 -0400 Subject: [PATCH 3/3] Test --- .github/workflows/release_tags.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release_tags.yml b/.github/workflows/release_tags.yml index 3448513..fb96dda 100644 --- a/.github/workflows/release_tags.yml +++ b/.github/workflows/release_tags.yml @@ -40,7 +40,3 @@ jobs: - name: git-tag-to-package-version run: npm version ${{ env.RELEASE_VERSION }} --no-git-tag-version - - - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.NPM_TOKEN }}