From c8796f8c93b008ae2112aa124831cb21da994856 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 23 Dec 2024 14:41:19 -0500 Subject: [PATCH] Auto generate github release on version change (#387) --- .github/workflows/publish.yml | 28 ------------------ .github/workflows/release.yml | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 2754212a10..0000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Publish to npm - -on: - pull_request: - types: [closed] - branches: - - main - - master - paths: - - "package.json" - -jobs: - publish: - runs-on: ubuntu-latest - if: > - github.event.pull_request.merged == true && - contains(github.event.pull_request.labels.*.name, 'Release') - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: lts/* - registry-url: "https://registry.npmjs.org" - - run: npm ci - - run: npm run build - - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..4aece640bf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Create a release + +on: + pull_request: + types: [closed] + branches: + - main + - master + paths: + - "package.json" + +jobs: + create-release: + runs-on: ubuntu-latest + if: > + github.event.pull_request.merged == true && + contains(github.event.pull_request.labels.*.name, 'Release') + steps: + - name: Checkout code + uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - name: Get current version + id: current_version + run: echo ::set-output name=version::$(node -p "require('./package.json').version") + - name: Create release + id: create_release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.current_version.outputs.version }} + draft: false + prerelease: false + generate_release_notes: true + make_latest: "true" + publish: + runs-on: ubuntu-latest + if: > + github.event.pull_request.merged == true && + contains(github.event.pull_request.labels.*.name, 'Release') + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + registry-url: "https://registry.npmjs.org" + - run: npm ci + - run: npm run build + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}