-
Notifications
You must be signed in to change notification settings - Fork 16
88 lines (79 loc) · 2.85 KB
/
cd.yml
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
name: "CD"
run-name: CD-${{ github.ref_name }}-${{ github.run_id }}-isPreview-${{ inputs.preview }}
on:
workflow_dispatch:
inputs:
release:
description: "replace AI key for release"
required: true
type: boolean
default: false
preview:
description: "generate prerelease vsix?"
required: true
type: boolean
default: false
tag:
description: "want to push tag to origin?"
required: false
type: boolean
default: false
schedule:
- cron: "0 16 * * *"
jobs:
CD:
permissions:
actions: read
contents: write
id-token: write
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: jossef/action-set-json-field@v1
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.release == 'true' || github.ref == 'refs/heads/main') }}
with:
file: ./package.json
field: aiKey
value: ${{ secrets.PUBLIC_AIKEY }}
- name: update visx for preview
if: ${{ github.event.inputs.preview == 'true'}}
run: |
VERSION=$(jq -r .version ./package.json)
echo '----------------- current version:' $VERSION
MINOR_VER=$(echo $VERSION | awk -F. '{print $2}')
DATE_WITH_TIME=`date "+%Y%m%d%H"`
if [ $((MINOR_VER%2)) -eq 0 ]; then
VERSION=$(echo ${VERSION%-*} | awk -v val=$DATE_WITH_TIME -F. '/[0-9]+\./{$2++;$3=val;print}' OFS=.)
else
VERSION=$(echo ${VERSION%-*} | awk -v val=$DATE_WITH_TIME -F. '/[0-9]+\./{$3=val;print}' OFS=.)
fi
echo '----------------- prerelease version:' $VERSION
jq --arg VERSION "$VERSION" '.version=$VERSION' package.json > tmp.$$.json
mv tmp.$$.json package.json
- name: Build visx
run: |
npm install
if [ "${{ github.event.inputs.preview }}" == "true" ]; then
npx @vscode/vsce package --no-dependencies --pre-release --githubBranch ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
else
npx @vscode/vsce package --no-dependencies --githubBranch ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
fi
- uses: actions/upload-artifact@v4
with:
name: release
path: |
*.vsix
package.json
- name: get package version
id: package-version
run: |
echo "version=$(jq -r '"v"+.version' package.json)" >> $GITHUB_OUTPUT
- uses: piszmog/create-tag@v1
if: ${{ github.event.inputs.tag == 'true'}}
with:
version: ${{ steps.package-version.outputs.version }}
message: "release ${{ steps.package-version.outputs.version }}"
token: ${{ secrets.GITHUB_TOKEN }}