diff --git a/.github/workflows/pr-workflow.yml b/.github/workflows/pr-workflow.yml index 232700e..4b69527 100644 --- a/.github/workflows/pr-workflow.yml +++ b/.github/workflows/pr-workflow.yml @@ -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 @@ -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: | @@ -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 \ No newline at end of file + 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 }} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9d13242..c308648 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mochawesome-json-to-md", - "version": "1.2.1", + "version": "1.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mochawesome-json-to-md", - "version": "1.2.1", + "version": "1.3.0", "license": "MIT", "dependencies": { "commander": "^11.1.0", diff --git a/package.json b/package.json index eee3b84..b44add0 100644 --- a/package.json +++ b/package.json @@ -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": {