-
Notifications
You must be signed in to change notification settings - Fork 9
137 lines (115 loc) · 4.25 KB
/
manual-publish.yml
File metadata and controls
137 lines (115 loc) · 4.25 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
name: Manual Package Publish
on:
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g., 1.0.0, patch, minor, major)"
required: true
default: "patch"
type: string
npm_tag:
description: "NPM tag to publish with (e.g., latest, beta, alpha)"
required: true
default: "latest"
type: string
dry_run:
description: "Run in dry-run mode (no actual publish)"
required: false
default: false
type: boolean
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.BASE44_GITHUB_ACTIONS_APP_ID }}
private-key: ${{ secrets.BASE44_GITHUB_ACTIONS_APP_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Enable corepack
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
registry-url: "https://registry.npmjs.org"
- name: Update npm
run: npm install -g npm@latest
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Check if version needs to be bumped
id: check-version
run: |
if [[ "${{ github.event.inputs.version }}" =~ ^(patch|minor|major)$ ]]; then
echo "bump_version=true" >> $GITHUB_OUTPUT
echo "version_type=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "bump_version=false" >> $GITHUB_OUTPUT
echo "version_type=" >> $GITHUB_OUTPUT
fi
- name: Bump version
if: steps.check-version.outputs.bump_version == 'true'
run: |
npm version ${{ steps.check-version.outputs.version_type }} --no-git-tag-version
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Set version manually
if: steps.check-version.outputs.bump_version == 'false'
run: |
npm version ${{ github.event.inputs.version }} --no-git-tag-version
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Show package info
run: |
echo "Package name: $(node -p "require('./package.json').name")"
echo "Version: ${{ env.NEW_VERSION }}"
echo "NPM tag: ${{ github.event.inputs.npm_tag }}"
echo "Dry run: ${{ github.event.inputs.dry_run }}"
- name: Publish to NPM
if: github.event.inputs.dry_run == 'false'
run: |
npm publish --tag ${{ github.event.inputs.npm_tag }}
- name: Dry run publish
if: github.event.inputs.dry_run == 'true'
run: |
npm publish --dry-run --tag ${{ github.event.inputs.npm_tag }}
- name: Create Git tag
if: github.event.inputs.dry_run == 'false'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add package.json package-lock.json
git commit -m "chore: bump version to ${{ env.NEW_VERSION }}"
git tag v${{ env.NEW_VERSION }}
git push origin HEAD:${{ github.ref }}
git push origin v${{ env.NEW_VERSION }}
- name: Create Release
if: github.event.inputs.dry_run == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.NEW_VERSION }}
release_name: Release v${{ env.NEW_VERSION }}
body: |
## What's Changed
This release includes the latest updates to the Base44 JavaScript SDK.
### Installation
```bash
npm install @base44/sdk@${{ github.event.inputs.npm_tag }}
```
### Version: ${{ env.NEW_VERSION }}
### NPM Tag: ${{ github.event.inputs.npm_tag }}
draft: false
prerelease: false
permissions:
contents: write
packages: write
id-token: write