From c48aa36655006cc980f47b43335d3ceeaa7087d4 Mon Sep 17 00:00:00 2001 From: YuitoAkatsuki Date: Fri, 12 Apr 2024 17:47:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20master=E3=81=AE=E3=82=B3=E3=83=9F?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=A7=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/bump.yaml | 49 +++++++++++++ .github/workflows/release.yml | 129 ---------------------------------- 2 files changed, 49 insertions(+), 129 deletions(-) create mode 100644 .github/workflows/bump.yaml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml new file mode 100644 index 0000000..5b1a420 --- /dev/null +++ b/.github/workflows/bump.yaml @@ -0,0 +1,49 @@ +name: Bump Version and Publish + +on: + push: + branches: + - master + +jobs: + bump_and_publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node.js and npm + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Set up Git + run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + + - name: Determine version bump + id: determine_bump + run: | + COMMIT_MESSAGE=$(git log --format=%B -n 1 $GITHUB_SHA) + if echo "$COMMIT_MESSAGE" | grep -q '\[Major\]'; then + echo "::set-output name=bump::major" + elif echo "$COMMIT_MESSAGE" | grep -q '\[Minor\]'; then + echo "::set-output name=bump::minor" + elif echo "$COMMIT_MESSAGE" | grep -q '\[Patch]'; then + echo "::set-output name=bump::patch" + elif echo "$COMMIT_MESSAGE" | grep -q '\[Prerelease]'; then + echo "::set-output name=bump::prerelease" + elif echo "$COMMIT_MESSAGE" | grep -q '\[Prepatch]'; then + echo "::set-output name=bump::prepatch" + else + exit 1; + fi + + - name: Bump version and publish + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + run: | + npm version ${{ steps.determine_bump.outputs.bump }} + git push --follow-tags \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a7fa709..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,129 +0,0 @@ -name: Release - -on: - pull_request: - types: [opened, reopened, labeled] - -jobs: - Patch: - runs-on: ubuntu-latest - if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' || contains(github.event.pull_request.labels[*].name, 'patch') }} - steps: - - name: Checkout Base Branch - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.base.ref }} - - - name: Version Get - run: | - NPM_VERSION=$(node -e "console.log(require('./package.json').version)") - printf "NPM_VERSION=%s" "$NPM_VERSION" >> $GITHUB_ENV - - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.ref }} - token: ${{ secrets.PAT }} - - - name: Version Get - run: | - NPM_NEW_VERSION=$(node -e "console.log(require('./package.json').version)") - printf "NPM_NEW_VERSION=%s" "$NPM_NEW_VERSION" >> $GITHUB_ENV - - - name: Automatic Rebase - uses: peter-evans/rebase@v3 - - - name: Update Version - if: ${{ env.NPM_VERSION >= env.NPM_NEW_VERSION }} - run: | - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" - npm version patch - - - name: Push changes - if: ${{ env.NPM_VERSION >= env.NPM_NEW_VERSION }} - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - run: | - git push -u -f origin ${{ github.event.pull_request.head.ref }} - - Minor: - runs-on: ubuntu-latest - if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' || contains(github.event.pull_request.labels[*].name, 'minor') }} - steps: - - name: Checkout Base Branch - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.base.ref }} - - - name: Version Get - run: | - NPM_VERSION=$(node -e "console.log(require('./package.json').version)") - printf "NPM_VERSION=%s" "$NPM_VERSION" >> $GITHUB_ENV - - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.ref }} - token: ${{ secrets.PAT }} - - - name: Version Get - run: | - NPM_NEW_VERSION=$(node -e "console.log(require('./package.json').version)") - printf "NPM_NEW_VERSION=%s" "$NPM_NEW_VERSION" >> $GITHUB_ENV - - - name: Automatic Rebase - uses: peter-evans/rebase@v3 - - - name: Update Version - if: ${{ env.NPM_VERSION >= env.NPM_NEW_VERSION }} - run: | - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" - npm version minor - - - name: Push changes - if: ${{ env.NPM_VERSION >= env.NPM_NEW_VERSION }} - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - run: | - git push -u -f origin ${{ github.event.pull_request.head.ref }} - - Major: - runs-on: ubuntu-latest - if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' || contains(github.event.pull_request.labels[*].name, 'major') }} - steps: - - name: Checkout Base Branch - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.base.ref }} - - - name: Version Get - run: | - NPM_VERSION=$(node -e "console.log(require('./package.json').version)") - printf "NPM_VERSION=%s" "$NPM_VERSION" >> $GITHUB_ENV - - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.ref }} - token: ${{ secrets.PAT }} - - - name: Version Get - run: | - NPM_NEW_VERSION=$(node -e "console.log(require('./package.json').version)") - printf "NPM_NEW_VERSION=%s" "$NPM_NEW_VERSION" >> $GITHUB_ENV - - - name: Automatic Rebase - uses: peter-evans/rebase@v3 - - - name: Update Version - if: ${{ env.NPM_VERSION >= env.NPM_NEW_VERSION }} - run: | - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" - npm version major - - - name: Push changes - if: ${{ env.NPM_VERSION >= env.NPM_NEW_VERSION }} - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - run: | - git push -u -f origin ${{ github.event.pull_request.head.ref }}