From 2d4a70e6397e604d2f3ed5469dc4bb05ff894cbb Mon Sep 17 00:00:00 2001 From: cjtim <47479090+cjtim@users.noreply.github.com> Date: Sat, 4 Jun 2022 15:06:59 +0700 Subject: [PATCH] feat(github action): add releaser --- .github/workflows/{build.yaml => release.yml} | 12 +++++-- .github/workflows/releaser.yml | 29 ++++++++++++++++ package.json | 33 ++++++++++++++++--- 3 files changed, 67 insertions(+), 7 deletions(-) rename .github/workflows/{build.yaml => release.yml} (85%) create mode 100644 .github/workflows/releaser.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/release.yml similarity index 85% rename from .github/workflows/build.yaml rename to .github/workflows/release.yml index 27e03f3..7b76e71 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/release.yml @@ -1,12 +1,17 @@ # This is a basic workflow to help you get started with Actions -name: build +name: Release # Controls when the action will run. on: push: - branches: [master, main] - pull_request: + tags: + - "**" workflow_dispatch: +permissions: + contents: write + packages: write + repository-projects: write + jobs: build: runs-on: ubuntu-latest @@ -40,4 +45,5 @@ jobs: push: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} tags: | ghcr.io/${{ github.repository }}:${{ github.sha }} + ghcr.io/${{ github.repository }}:${{ github.ref_name }} ghcr.io/${{ github.repository }}:latest \ No newline at end of file diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml new file mode 100644 index 0000000..52ae232 --- /dev/null +++ b/.github/workflows/releaser.yml @@ -0,0 +1,29 @@ +name: Releaser +on: + push: + branches: + - master + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Release + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.PUSH_PAT }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 02dd0ab..a274f59 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "be-friends", - "version": "0.1.0", + "version": "0.0.0-development", "private": true, "scripts": { "dev": "next dev", @@ -12,7 +12,8 @@ "format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}'", "prepare": "husky install", "generate": "prisma generate", - "migrate": "prisma migrate" + "migrate": "prisma migrate", + "semantic-release": "semantic-release" }, "dependencies": { "@chakra-ui/icons": "^2.0.1", @@ -37,9 +38,33 @@ "eslint-config-prettier": "^8.5.0", "husky": "^8.0.1", "prettier": "^2.6.2", - "typescript": "4.6.4" + "typescript": "4.6.4", + "semantic-release": "^19.0.2" }, "engines": { "node": ">=14" - } + }, + "repository": { + "type": "git", + "url": "https://github.com/cjtim/be-friends.git" + }, + "publishConfig": { + "access": "restricted" + }, + "release": { + "branches": [ + "master" + ] + }, + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/npm", + { + "npmPublish": false + } + ], + "@semantic-release/git" + ] }