Skip to content

Commit

Permalink
merge(#42): feat: automatic gh releases and npm publishes
Browse files Browse the repository at this point in the history
feat: automatic gh releases and npm publishes
  • Loading branch information
403-html committed Feb 16, 2024
2 parents 9a08b7b + 4697c9e commit 7659cfa
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
48 changes: 47 additions & 1 deletion .github/workflows/pr-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ on:
types:
- opened
- synchronize
push:
branches:
- main

jobs:
semver-check:
if: github.event.action == 'opened'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Reattach HEAD
uses: actions/checkout@v2
Expand Down Expand Up @@ -52,6 +57,10 @@ jobs:
echo "Error: working branch prefix not found"
exit 1
fi
- name: Get version number
id: get-version
run: echo "::set-output name=version::$(git describe --tags --abbrev=0)"

- name: Setup git
run: |
Expand Down Expand Up @@ -79,4 +88,41 @@ jobs:
if [[ ! $pr_name =~ ^(feat|fix|chore|docs|misc)(\([a-zA-Z]+\))?!?:\ .*$ ]]; then
echo "error: Pull request title must start with feat/fix/chore/docs/misc, followed by optional ! for breaking changes, followed by an optional scope in parentheses, followed by a colon, followed by a space, followed by a description."
exit 1
fi
fi
gh-release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- semver-check
steps:
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: "New release ${{ needs.semver-check.outputs.version }}"
tag_name: ${{ needs.semver-check.outputs.version }}
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-npm:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- semver-check
- gh-release
steps:
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mochawesome-json-to-md",
"version": "1.2.1",
"version": "1.3.0",
"description": "A repository containing a script to convert JSON reports generated by MochAwesome to Mardown",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 7659cfa

Please sign in to comment.