Skip to content

Commit

Permalink
ci: initial build & publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ScarletFlash committed Nov 10, 2024
1 parent 73e24cc commit 0482de6
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build & Push

on:
workflow_dispatch:
push:
branches:
- "main"
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}-${{ github.event_name }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
build_and_push:
runs-on: ubuntu-latest
name: Build and publish
steps:
- name: "Fetch all required Git history"
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
package_json_file: package.json

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build library
run: pnpm run build

- name: Publish package
run: |
cd dist
CURRENT_VERSION=$(grep --only-matching --perl-regexp '"version":\s*"\K[^"]+' package.json)
TARGET_VERSION="$CURRENT_VERSION-sha.${{github.sha}}"
if pnpm view multiprovider@"${TARGET_VERSION}" > /dev/null 2>&1; then
echo "Version already exists. Skipping publish."
else
cd bundle
pnpm version ${TARGET_VERSION}
pnpm config set //registry.npmjs.org/:_authToken ${NODE_AUTH_TOKEN}
pnpm publish --access public --no-git-checks
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@
"typescript": "^5.0.0",
"vite": "^5.0.0",
"vite-plugin-dts": "^4.0.0"
}
},
"engines": {
"pnpm": "9.12.2",
"node": "22.10.0"
},
"packageManager": "[email protected]"
}

0 comments on commit 0482de6

Please sign in to comment.