From 68c31d2b0e46c718d4e932ceedbd6d489866caa7 Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Fri, 23 Feb 2024 17:40:45 +0200 Subject: [PATCH] chore: add gh actions There is no build step, but keep it for later reference. --- .github/workflows/publish.yml | 20 ++++++++++++++++ .github/workflows/release_on_tag.yml | 32 ++++++++++++++++++++++++++ .github/workflows/require_pr_label.yml | 13 +++++++++++ 3 files changed, 65 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release_on_tag.yml create mode 100644 .github/workflows/require_pr_label.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5fe3d24 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,20 @@ +name: Publish to npm + +# https://stackoverflow.com/questions/69063452/github-actions-on-release-created-workflow-trigger-not-working +on: + workflow_run: + workflows: ["Release on tag"] + types: [completed] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release_on_tag.yml b/.github/workflows/release_on_tag.yml new file mode 100644 index 0000000..3cd9b7c --- /dev/null +++ b/.github/workflows/release_on_tag.yml @@ -0,0 +1,32 @@ +name: 'Release on tag' +on: + push: + tags: + - '*' + +jobs: + release: + permissions: + contents: write + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # - uses: actions/setup-node@v3 + # with: + # node-version: '20.x' + # registry-url: 'https://registry.npmjs.org' + # - run: npm install && npm run build && npm pack + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }} + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + body: ${{steps.github_release.outputs.changelog}} + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }} \ No newline at end of file diff --git a/.github/workflows/require_pr_label.yml b/.github/workflows/require_pr_label.yml new file mode 100644 index 0000000..2049896 --- /dev/null +++ b/.github/workflows/require_pr_label.yml @@ -0,0 +1,13 @@ +name: Pull Request Labels +on: + pull_request: + types: [opened, labeled, unlabeled, synchronize] +jobs: + label: + runs-on: ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v1 + with: + mode: exactly + count: 1 + labels: "fix, feature, doc, chore, test, ignore, other, dependencies" \ No newline at end of file