Skip to content

Commit 125cc2f

Browse files
committed
update: add GitHub workflows for release and publish
1 parent a660528 commit 125cc2f

File tree

14 files changed

+669
-236
lines changed

14 files changed

+669
-236
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: npv2k1
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
on:
2+
push:
3+
tags:
4+
- "v*"
5+
6+
name: Create Release
7+
8+
jobs:
9+
create-release:
10+
name: Publish Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Pull all submodule
17+
run: git submodule update --init --recursive
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: "16"
23+
24+
- name: Setup Git
25+
run: |
26+
git config user.name '${{secrets.MAINTAINER_NAME}}'
27+
git config user.email '${{secrets.MAINTAINER_EMAIL}}'
28+
29+
- name: Update package.json
30+
run: |
31+
# Extract the version from the git tag (e.g., "v1.0.0")
32+
version=$(echo "${{ github.ref }}" | sed -e 's/^refs\/tags\/v//')
33+
34+
# Update the package.json version using Node.js script
35+
node - <<EOF
36+
const fs = require('fs');
37+
const packageJson = JSON.parse(fs.readFileSync('package.json'));
38+
packageJson.version = "$version";
39+
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
40+
EOF
41+
42+
- uses: pnpm/action-setup@v2
43+
name: Install pnpm
44+
id: pnpm-install
45+
with:
46+
version: 7
47+
run_install: false
48+
49+
- name: Get pnpm store directory
50+
id: pnpm-cache
51+
shell: bash
52+
run: |
53+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
54+
55+
- uses: actions/cache@v3
56+
name: Setup pnpm cache
57+
with:
58+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
59+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
60+
restore-keys: |
61+
${{ runner.os }}-pnpm-store-
62+
63+
- name: Install dependencies
64+
run: pnpm install
65+
66+
- name: Build package
67+
run: pnpm run build
68+
69+
- uses: actions/create-release@v1
70+
id: create_release
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
tag_name: ${{ github.ref }}
75+
release_name: ${{ github.ref }}
76+
draft: true

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Publish Release
2+
on:
3+
release:
4+
types:
5+
- published
6+
7+
jobs:
8+
publish-release:
9+
name: Publish Release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Pull all submodule
16+
run: git submodule update --init --recursive
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: "16"
22+
23+
- name: Setup Git
24+
run: |
25+
git config user.name '${{secrets.MAINTAINER_NAME}}'
26+
git config user.email '${{secrets.MAINTAINER_EMAIL}}'
27+
28+
- name: Update package.json
29+
run: |
30+
# Extract the version from the git tag (e.g., "v1.0.0")
31+
version=$(echo "${{ github.event.release.tag_name }}" | sed -e 's/^refs\/tags\/v//')
32+
33+
# Update the package.json version using Node.js script
34+
node - <<EOF
35+
const fs = require('fs');
36+
const packageJson = JSON.parse(fs.readFileSync('package.json'));
37+
packageJson.version = "$version";
38+
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
39+
EOF
40+
41+
- uses: pnpm/action-setup@v2
42+
name: Install pnpm
43+
id: pnpm-install
44+
with:
45+
version: 7
46+
run_install: false
47+
48+
- name: Get pnpm store directory
49+
id: pnpm-cache
50+
shell: bash
51+
run: |
52+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
53+
54+
- uses: actions/cache@v3
55+
name: Setup pnpm cache
56+
with:
57+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
58+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
59+
restore-keys: |
60+
${{ runner.os }}-pnpm-store-
61+
62+
- name: Install dependencies
63+
run: pnpm install
64+
65+
- name: Build package
66+
run: pnpm run build
67+
68+
- name: Publish
69+
run: |
70+
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
71+
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
72+
npm publish --tag beta
73+
else
74+
npm publish
75+
fi
76+
env:
77+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/publish.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.github/workflows/sub-module.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
workflow_dispatch:
3+
4+
name: Sync Submodule
5+
6+
env:
7+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8+
9+
jobs:
10+
sync-submodule:
11+
name: Sync Submodule
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Pull all submodule
18+
run: git submodule update --init --recursive
19+
20+
- name: Setup Git
21+
run: |
22+
git config user.name '${{secrets.MAINTAINER_NAME}}'
23+
git config user.email '${{secrets.MAINTAINER_EMAIL}}'
24+
25+
- name: Create new branch
26+
run: git checkout -b submodule-sync-${{ github.sha }}
27+
28+
- name: Sync submodule
29+
run: |
30+
git submodule update --remote --merge
31+
32+
- name: Create branch
33+
run: |
34+
git add .
35+
git commit -m "Sync submodules - Updated submodules" || echo "No changes to commit"
36+
git push origin submodule-sync-${{ github.sha }}

0 commit comments

Comments
 (0)