diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fd76955 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,69 @@ +name: Release +on: + workflow_dispatch: + inputs: + release-type: + description: "Release type" + required: true + default: "patch" + type: choice + options: + - patch + - minor + - major + - prepatch + - preminor + - premajor + - prerelease + +env: + node_version: 18 + +concurrency: + group: release + cancel-in-progress: true + +permissions: write-all + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node.js ${{ env.node_version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.node_version }} + # setting a registry enables the NODE_AUTH_TOKEN env variable where we can set a npm token. REQUIRED + registry-url: 'https://registry.npmjs.org' + + - name: Prepare modules + run: npm ci + + - name: Run tests + run: npm test + + - name: Setup Git + run: | + git config --global user.email "sikrinick@gmail.com" + git config --global user.name "${{ github.actor }}" + + - name: Increment package version and add tag + run: npm version ${{ github.event.inputs.release-type }} + + - name: Release Tag + id: release-tag-retriever + run: echo "release-tag=$(git describe --tags)" >> $GITHUB_OUTPUT + + - name: Push commit and tag + run: git push --follow-tags + + - name: Publish to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Print Release tag + run: echo ${{ steps.release-tag-retreiver.outputs.release-tag }} diff --git a/.npmignore b/.npmignore index c38fa4e..85cbc3c 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ +.github .idea *.iml