Skip to content

Commit dbaeec4

Browse files
committed
[CI/CD] add npm tag release action
1 parent 4faa96b commit dbaeec4

4 files changed

Lines changed: 32 additions & 24 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,17 @@ jobs:
2727
env:
2828
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2929

30-
# - name: Configure Yarn authentication
31-
# run: |
32-
# echo 'npmRegistryServer: "https://registry.npmjs.org"' >> .yarnrc.yml
33-
# echo 'npmAlwaysAuth: true' >> .yarnrc.yml
34-
# echo 'npmAuthToken: "${{ secrets.NPM_TOKEN }}"' >> .yarnrc.yml
35-
3630
- name: Install dependencies (Yarn Berry)
3731
run: yarn install --immutable
3832
env:
3933
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4034

41-
- name: Debug .yarnrc.yml
42-
run: cat .yarnrc.yml
43-
continue-on-error: true
44-
4535
- name: Run tests (if test script exists)
4636
run: yarn workspaces foreach --all --topological --parallel --no-private run test
4737
continue-on-error: true
4838

4939
- name: Build project (if build script exists)
5040
run: yarn workspaces foreach --all --topological --parallel --no-private run build
51-
continue-on-error: true
5241

5342
- name: Bump version & commit (only on main)
5443
if: github.ref == 'refs/heads/main'
@@ -66,8 +55,24 @@ jobs:
6655
- name: Publish to npm using yarn workspaces
6756
if: github.ref == 'refs/heads/main'
6857
run: yarn workspaces foreach --verbose --all --topological --no-private npm publish --access public
58+
59+
get-version:
60+
runs-on: ubuntu-latest
61+
outputs:
62+
version: ${{ steps.get-version.outputs.version }}
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
6966

70-
71-
72-
67+
- name: Get version from package.json
68+
id: get-version
69+
run: |
70+
VERSION=$(jq -r .version package.json)
71+
echo "version=$VERSION" >> $GITHUB_OUTPUT
72+
73+
call-publish:
74+
needs: get-version
75+
uses: ./.github/workflows/release.yml
76+
with:
77+
version: ${{ needs.get-version.outputs.version }}
7378

.github/workflows/release.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: Create GitHub Release
22

33
on:
4-
push:
5-
tags:
6-
- "v*.*.*"
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
79

810
jobs:
911
release:
@@ -16,12 +18,12 @@ jobs:
1618
- name: Create GitHub Release
1719
uses: softprops/action-gh-release@v1
1820
with:
19-
tag_name: ${{ github.ref_name }}
20-
name: Release ${{ github.ref_name }}
21+
tag_name: ${{ inputs.version }}
22+
name: Release ${{ inputs.version }}
2123
body: |
22-
**New Release: ${{ github.ref_name }}**
24+
**New Release: ${{ inputs.version }}**
2325
24-
- 📦 **NPM Package**: [View on npm](https://www.npmjs.com/package/spreadsheet-orm)
26+
- 📦 **NPM Package**: [View on npm](https://www.npmjs.com/package/spreadsheet-orm/v/${{ inputs.version }})
2527
2628
draft: false
2729
prerelease: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ build/
2828

2929
.turbo
3030
.npmrc
31+
.yarnrc.local.yml

packages/main/src/config/SpreadConfig.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { GaxiosError } from "gaxios";
22
import { google, sheets_v4 } from "googleapis";
33

44
export interface SpreadsheetConfigOptions{
5-
ID:string;
5+
spreadsheetID:string;
66
email: string; // service acount email
77
privateKey: string; // Google API key
88
}
@@ -16,7 +16,7 @@ class SpreadConfig{
1616
})
1717
}
1818

19-
static extractSheetIDfromURL(url:string):SpreadsheetConfigOptions['ID'] | false{
19+
static extractSheetIDfromURL(url:string):SpreadsheetConfigOptions['spreadsheetID'] | false{
2020
const regex = /\/d\/([a-zA-Z0-9_-]{43})/; // extract sheet id from url
2121
const match = url.match(regex);
2222
if (match && match[1]) {
@@ -36,7 +36,7 @@ class SpreadConfig{
3636

3737
constructor(options:SpreadsheetConfigOptions){
3838
this.checkFormat(options)
39-
this.ID = SpreadConfig.extractSheetIDfromURL(options.ID) || options.ID
39+
this.ID = SpreadConfig.extractSheetIDfromURL(options.spreadsheetID) || options.spreadsheetID
4040
this.authJWT = SpreadConfig.makeAuthJWT({email:options.email, privateKey:options.privateKey})
4141
this.API = google.sheets({
4242
version:'v4',

0 commit comments

Comments
 (0)