Skip to content

Commit

Permalink
ci: separate ci & release
Browse files Browse the repository at this point in the history
We'll deploy release by `bumpp`
  • Loading branch information
FlandreDaisuki committed Nov 5, 2023
1 parent 35c79f1 commit 22ba215
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 60 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches:
- master

pull_request:
branches:
- master

jobs:
run-test:
name: 🧪 Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Setup pnpm
id: setup-pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> "${GITHUB_OUTPUT}"
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install

- run: pnpm run test
52 changes: 0 additions & 52 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,12 @@ on:
types: [published]

jobs:
run-test:
name: 🧪 Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Setup pnpm
id: setup-pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> "${GITHUB_OUTPUT}"
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install

- run: pnpm run test

deploy-to-npm:
name: 📦 Deploy to npm
runs-on: ubuntu-latest
needs: [run-test]
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

build-and-push-image:
name: 🐳 Build image & deploy to ghcr.io
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [run-test]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
},
"scripts": {
"lint": "eslint . --fix",
"test": "vitest"
"test": "vitest",
"release": "bumpp && pnpm publish"
},
"dependencies": {
"aria2": "^4.1.2",
Expand All @@ -45,6 +46,7 @@
"@types/node": "^20.8.3",
"@types/semver": "^7.5.3",
"@types/yargs": "^17.0.28",
"bumpp": "^9.2.0",
"eslint": "^8.53.0",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
Expand Down
Loading

0 comments on commit 22ba215

Please sign in to comment.