CD-dev-12308273660-isPreview-true #414
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
with: | |
version: ${{ steps.package-version.outputs.version }} | |
message: "release ${{ steps.package-version.outputs.version }}" | |
token: ${{ secrets.GITHUB_TOKEN }} |