Skip to content

Commit

Permalink
new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptPilot committed Feb 14, 2024
1 parent 7e48cac commit d75dd7a
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 46 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
on:
push:
branches:
- main
paths:
- package.json

concurrency:
group: main

jobs:

check-conditions:
runs-on: ubuntu-latest
outputs:
isNewVersion: ${{ steps.check-tag.outputs.exists == 'false' }}
npmTokenAvailable: ${{ steps.npm.outputs.available }}
steps:

- name: Checkout the repository
uses: actions/checkout@v4

- name: Get the package version tag
id: package-version
run: echo "tag=v$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT

- name: Check if tag exists
uses: mukunku/[email protected]
id: check-tag
with:
tag: ${{ steps.package-version.outputs.tag }}

- name: Check if NPM token secret is available
id: npm
run: echo "available=${{ secrets.NPM_TOKEN != '' }}" >> $GITHUB_OUTPUT

release:
runs-on: ubuntu-latest
permissions: write-all
needs: build
steps:

- name: Create a new version tag
uses: Klemensas/action-autotag@stable
id: tag
with:
tag_prefix: v
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create the changelog
uses: heinrichreimer/[email protected]
id: changelog
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Extract the release notes
uses: actions-ecosystem/action-regex-match@v2
id: releasenotes
with:
text: ${{ steps.changelog.outputs.changelog }}
regex: ^(\n|.)*?(##(.+)\n\n((\n|.)*?))(\n)+(##(\n|.)*)?(\n)+\\\*(.+)$

- name: Create a new GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag.outputs.tagname }}
body: ${{ steps.releasenotes.outputs.group4 }}
artifacts: release-artifacts/*

deploy-npm:
runs-on: ubuntu-latest
permissions: write-all
needs:
- release
- check-conditions
if: needs.check-conditions.outputs.npmTokenAvailable == 'true'
steps:

- name: Checkout the repository
uses: actions/checkout@v4

- name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
with:
access: public
token: ${{ secrets.NPM_TOKEN }}
46 changes: 0 additions & 46 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit d75dd7a

Please sign in to comment.