From 2dbaa67c18f9d7f8fec6ef2a14bb550805f503d4 Mon Sep 17 00:00:00 2001 From: MinhOmega Date: Sat, 14 Sep 2024 02:09:04 +0700 Subject: [PATCH] ci: update structure of github action and implement release workflow --- .github/actions/setup/action.yml | 28 ++++++++++++++++++++++ .github/workflows/ci.yml | 21 +--------------- .github/workflows/release.yml | 41 ++++++++++++++++++++++++++++++++ package.json | 8 +++---- 4 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..8b29db0 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,28 @@ +name: 'Setup Environment' +description: 'Sets up Node.js and Yarn dependencies' + +runs: + using: "composite" + steps: + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + shell: bash + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Cache yarn dependencies + uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + shell: bash + run: yarn install --frozen-lockfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c4addf..af50bbe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,26 +22,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - - name: Cache yarn dependencies - uses: actions/cache@v3 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Install dependencies - run: yarn install --frozen-lockfile + - uses: ./.github/actions/setup - name: Run tests with coverage run: yarn test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..946f5d6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release' + required: true + +permissions: + contents: write + pull-requests: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: ./.github/actions/setup + + - name: Run release-it + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + yarn release ${{ github.event.inputs.version }} --ci + + - name: Push changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git push --follow-tags + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ github.event.inputs.version }} --generate-notes diff --git a/package.json b/package.json index bf334a6..de6170c 100644 --- a/package.json +++ b/package.json @@ -53,15 +53,13 @@ "git": { "commitMessage": "chore: release ${version}", "tagName": "v${version}", - "commitMode": "direct", - "push": true + "push": false }, "npm": { - "publish": true + "publish": false }, "github": { - "release": true, - "web": true + "release": false }, "plugins": { "@release-it/conventional-changelog": {