-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (118 loc) · 4.72 KB
/
prerelease-node-sdk.yml
File metadata and controls
141 lines (118 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: WIP Release Node SDK
permissions:
contents: write
packages: write
on:
workflow_dispatch:
inputs:
tag:
description: 'NPM distribution tag (e.g. beta, alpha, next)'
required: true
default: 'beta'
branch:
description: 'Branch containing the WIP changes (you can specify any branch name)'
required: true
default: 'main'
jobs:
wip-release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/node/iii
steps:
- name: Warning
working-directory: .
run: |
echo "⚠️ WARNING: WIP Release bypasses the approval gate"
echo "This workflow should only be used for testing purposes"
echo "For production releases, use the Create Tag workflow instead"
echo ""
echo "Publishing to NPM tag: ${{ github.event.inputs.tag }}"
echo "From branch: ${{ github.event.inputs.branch }}"
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.III_CI_APP_ID }}
private-key: ${{ secrets.III_CI_APP_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
run_install: false
- name: Get pnpm store directory
shell: bash
working-directory: .
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Git
working-directory: .
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Install dependencies
working-directory: packages/node
run: pnpm install --frozen-lockfile
- name: Get current version
id: current_version
run: |
current_version=$(node -p "require('./package.json').version")
echo "Current version: $current_version"
echo "version=$current_version" >> $GITHUB_OUTPUT
- name: Bump version with timestamp
id: version
run: |
tag="${{ github.event.inputs.tag }}"
current_version=$(node -p "require('./package.json').version")
base_version=$(echo $current_version | cut -d'-' -f1)
IFS='.' read -r major minor patch <<< "$base_version"
timestamp=$(date +%Y%m%d%H%M%S)
new_version="${major}.${minor}.${patch}-${tag}.${timestamp}"
echo "Setting version to: $new_version"
pnpm version $new_version --no-git-tag-version
echo "version=$new_version" >> $GITHUB_OUTPUT
- name: Show version information
working-directory: .
run: |
echo "### Version Information" >> $GITHUB_STEP_SUMMARY
echo "- **Package:** iii-sdk" >> $GITHUB_STEP_SUMMARY
echo "- **Current version:** ${{ steps.current_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **New version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **NPM distribution tag:** ${{ github.event.inputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.event.inputs.branch }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "npm install iii-sdk@${{ github.event.inputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "npm install iii-sdk@${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Build SDK
run: pnpm run build
- name: Setup NPM authentication
working-directory: packages/node
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
- name: Publish package with custom tag
working-directory: packages/node
run: |
pnpm publish -r --filter iii-sdk --no-git-checks --tag ${{ github.event.inputs.tag }}