-
Notifications
You must be signed in to change notification settings - Fork 17
168 lines (151 loc) · 5.63 KB
/
release-cli.yml
File metadata and controls
168 lines (151 loc) · 5.63 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Build and Release Yaci CLI Zip
on:
push:
tags:
- 'v*'
- 'rel-cli-*'
jobs:
buildAndPush:
strategy:
matrix:
os: ["ubuntu-22.04", "macos-14"]
runs-on: ${{ matrix.os }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
FORCE_COLOR: 1
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
version: '21.0.5'
native-image-job-reports: 'true'
- name: Get Tag from version file
run: |
TAG=$(grep "tag=" config/version | cut -d'=' -f2)
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Grant execute permission for gradlew
working-directory: applications/cli
run: chmod +x gradlew
- name: Set OS prefix
working-directory: applications/cli
if: runner.os == 'Linux'
run: |
echo "os_prefix=linux" >> $GITHUB_ENV
- name: MacOS specific env
if: runner.os == 'macOS'
run: |
echo "os_prefix=macos" >> $GITHUB_ENV
- name: Build with Gradle
working-directory: applications/cli
run: ./gradlew --no-daemon -i -Pversion=${{ env.TAG }} clean build nativeCompile cliZip
- name: Copy zip artifacts
working-directory: applications/cli
run: mv build/yaci-cli-${{ env.TAG }}.zip build/yaci-cli-${{ env.TAG }}-${{ env.os_prefix }}-${{ runner.arch }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: yaci-cli-${{ matrix.os }}
path: |
applications/cli/build/native/nativeCompile/yaci-cli
applications/cli/config
retention-days: 2
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./applications/cli/build/yaci-cli-${{ env.TAG }}-${{ env.os_prefix }}-${{ runner.arch }}.zip
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm-publish:
needs: buildAndPush
strategy:
matrix:
os: [ "ubuntu-22.04", "macos-14" ]
runs-on: ${{ matrix.os }}
env:
FORCE_COLOR: 1
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Get Tag from version file
run: |
TAG=$(grep "tag=" config/version | cut -d'=' -f2)
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: yaci-cli-${{ matrix.os }}
- name: Determine Platform-Specific Folder
id: platform-folder
run: |
if [[ "${{ matrix.os }}" == "ubuntu-22.04" ]]; then
echo "npm_folder=yaci-devkit-linux-x64" >> $GITHUB_ENV
elif [[ "${{ matrix.os }}" == "macos-14" ]]; then
echo "npm_folder=yaci-devkit-macos-arm64" >> $GITHUB_ENV
fi
echo "npm_folder=${{ env.npm_folder }}"
- name: Prepare npm package
run: |
cp build/native/nativeCompile/yaci-cli npm/${{ env.npm_folder }}/
cp -r config npm/${{ env.npm_folder }}/
- name: Set npm package version
working-directory: npm/${{ env.npm_folder }}
run: npm version ${{ env.TAG }} --no-git-tag-version
- name: Configure npm for scoped package
run: |
echo "@my-org:registry=https://registry.npmjs.org/" >> ~/.npmrc
- name: Publish to npm
working-directory: npm/${{ env.npm_folder }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [[ "${{ env.TAG }}" == *"-preview"* ]]; then
npm publish --access public --tag preview
elif [[ "${{ env.TAG }}" == *"-beta"* ]]; then
npm publish --access public --tag beta
else
npm publish --access public
fi
publish-yaci-devkit:
needs: npm-publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Get Tag from version file
run: |
TAG=$(grep "tag=" config/version | cut -d'=' -f2)
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Update `yaci-devkit` Version and Dependencies
working-directory: npm/yaci-devkit
run: |
# Update the version
npm version ${{ env.TAG }} --no-git-tag-version
# Update platform-specific dependency versions
sed -i "s/\"@bloxbean\/yaci-devkit-macos-arm64\": \".*\"/\"@bloxbean\/yaci-devkit-macos-arm64\": \"${{ env.TAG }}\"/" package.json
sed -i "s/\"@bloxbean\/yaci-devkit-linux-x64\": \".*\"/\"@bloxbean\/yaci-devkit-linux-x64\": \"${{ env.TAG }}\"/" package.json
- name: Publish `yaci-devkit` to npm
working-directory: npm/yaci-devkit
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [[ "${{ env.TAG }}" == *"-preview"* ]]; then
npm publish --access public --tag preview
elif [[ "${{ env.TAG }}" == *"-beta"* ]]; then
npm publish --access public --tag beta
else
npm publish --access public
fi