forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (103 loc) · 4.29 KB
/
publish_release.yml
File metadata and controls
121 lines (103 loc) · 4.29 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
name: publish
on:
workflow_dispatch:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "src/v1.x"
timeout-minutes: 10
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: "9.5"
- name: Install Dependencies
run: pnpm i
- name: Is in prerelease mode
id: is-in-prerelease-mode
run: |
if [ -f ".changeset/pre.json" ]; then
MODE=$(node -p "require('./.changeset/pre.json').mode")
if [ "$MODE" = "exit" ]; then
echo "::set-output name=is_in_prerelease_mode::false"
elif [ "$MODE" = "pre" ]; then
echo "::set-output name=is_in_prerelease_mode::true"
fi
else
echo "::set-output name=is_in_prerelease_mode::false"
fi
- name: Get current version
id: current-version
run: |
echo "version=$(node -p "require('./packages/react-core/package.json').version")" >> "$GITHUB_OUTPUT"
- name: NPM Publish
id: publish
run: |
pnpm changeset version
pnpm run build
pnpm changeset publish --no-git-tag 2>&1 | tee publish-output.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Get new version
id: new-version
run: |
echo "version=$(node -p "require('./packages/react-core/package.json').version")" >> "$GITHUB_OUTPUT"
- name: Check if published
id: check-if-published
run: |
sleep 3
PUBLISHED=$(node -p "const fs = require('fs'); fs.readFileSync('./publish-output.txt', 'utf-8').includes('packages published successfully:')")
echo "published=$PUBLISHED" >> "$GITHUB_OUTPUT"
- name: Print variables
run: |
echo "New version: ${{ steps.new-version.outputs.version }}"
echo "Current version: ${{ steps.current-version.outputs.version }}"
echo "Published: ${{ steps.check-if-published.outputs.published }}"
echo "Is in prerelease mode: ${{ steps.is-in-prerelease-mode.outputs.is_in_prerelease_mode }}"
- name: Update changeset state post-release
if: ${{ steps.check-if-published.outputs.published == 'true' }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add .
if [ ! -f ".changeset/pre.json" ]; then
pnpm changeset pre enter next
fi
git add ./.changeset/pre.json
git commit -m "chore(post-release): update version to ${{ steps.new-version.outputs.version }}"
git push origin main --force
- name: Git Tag
if: ${{ steps.check-if-published.outputs.published == 'true' && steps.is-in-prerelease-mode.outputs.is_in_prerelease_mode == 'false' }}
run: |
node -p "require('./scripts/release/generate-changelog')('${{ steps.new-version.outputs.version }}')" > changelog.txt
git tag -a v${{ steps.new-version.outputs.version }} -m "Release ${{ steps.new-version.outputs.version }}"
git push origin v${{ steps.new-version.outputs.version }}
git push origin main --force
- name: Create Release
if: ${{ steps.check-if-published.outputs.published == 'true' && steps.is-in-prerelease-mode.outputs.is_in_prerelease_mode == 'false' }}
id: create_release
uses: comnoco/create-release-action@v2.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: v${{ steps.new-version.outputs.version }}
release_name: v${{ steps.new-version.outputs.version }}
body_path: ./src/v1.x/changelog.txt
draft: false
prerelease: false