diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..097f2ea --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release + +on: + workflow_dispatch: + inputs: + mode: + description: "Release mode" + required: true + default: "no publish" + type: choice + options: + - "no publish" + - "publish" + push: + branches: + - main + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + + - name: Install Dependencies + run: npm ci + + - name: Get Package Version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.3.1 + + - name: No Publish Build and Pack + if: ${{ github.event_name == 'workflow_dispatch' && inputs.mode == 'no publish' }} + run: | + npm run build + npm pack + + - name: No Publish Artifact Upload + if: ${{ github.event_name == 'workflow_dispatch' && inputs.mode == 'no publish' }} + uses: actions/upload-artifact@v4 + with: + name: package-artifact + path: prettier-plugin-embed-${{steps.package-version.outputs.current-version}}.tgz + retention-days: 1 + overwrite: true + + - name: Create Release Pull Request or Publish to npm + if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'publish') }} + id: changesets + uses: changesets/action@v1 + with: + publish: npm publish + commit: "chore(release): v${{steps.package-version.outputs.current-version}}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..32b6e49 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +node \ No newline at end of file