-
Notifications
You must be signed in to change notification settings - Fork 3
122 lines (109 loc) · 4.25 KB
/
Copy pathrelease.yml
File metadata and controls
122 lines (109 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
name: Build and Release
on:
push:
branches: [main]
paths:
- 'zendesk_app/manifest.json'
- 'zendesk_app/src/manifest.json'
jobs:
release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: zendesk_app
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: zendesk_app/package-lock.json
- name: Get version
id: get_version
run: |
VERSION=$(node -p "require('./src/manifest.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create and push tag
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
run: |
git config user.email "stan@quivr.app"
git config user.name "StanGirard"
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Version ${{ steps.get_version.outputs.version }}"
git push origin "v${{ steps.get_version.outputs.version }}"
- name: Install dependencies
run: npm install
- name: Install ZCLI
run: npm i @zendesk/zcli -g
# Build Preview Version
- name: Build Preview Version
env:
ZENDESK_SUBDOMAIN: ${{ secrets.ZENDESK_PREVIEW_SUBDOMAIN }}
ZENDESK_EMAIL: ${{ secrets.ZENDESK_PREVIEW_EMAIL }}
ZENDESK_API_TOKEN: ${{ secrets.ZENDESK_PREVIEW_API_TOKEN }}
run: |
# Replace API URLs with preview URL
sed -i 's|https://api.quivr.app|https://api-preview.quivr.app|g' src/app/services/quivr.ts
sed -i 's|https://api.quivr.app|https://api-preview.quivr.app|g' src/app/contexts/QuivrApiProvider.tsx
sed -i 's|http://localhost:3000/modal|assets/modal.html|g' src/app/components/RightPanelApp/components/ResponseContainer/ResponseContainer.tsx
npm run build
zcli apps:package dist
ZIP_FILE=$(find . -name "app-*.zip" -type f)
if [ $(echo "$ZIP_FILE" | wc -l) -ne 1 ]; then
echo "Error: Found multiple or no zip files"
exit 1
fi
mv "$ZIP_FILE" preview.zip
# Build Production Version
- name: Build Production Version
env:
ZENDESK_SUBDOMAIN: ${{ secrets.ZENDESK_PROD_SUBDOMAIN }}
ZENDESK_EMAIL: ${{ secrets.ZENDESK_PROD_EMAIL }}
ZENDESK_API_TOKEN: ${{ secrets.ZENDESK_PROD_API_TOKEN }}
run: |
# Restore original API URLs
sed -i 's|https://api-preview.quivr.app|https://api.quivr.app|g' src/app/services/quivr.ts
sed -i 's|https://api-preview.quivr.app|https://api.quivr.app|g' src/app/contexts/QuivrApiProvider.tsx
rm -rf dist
npm run build
zcli apps:package dist
ZIP_FILE=$(find . -name "app-*.zip" -type f)
if [ $(echo "$ZIP_FILE" | wc -l) -ne 1 ]; then
echo "Error: Found multiple or no zip files"
exit 1
fi
mv "$ZIP_FILE" production.zip
# Create GitHub Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Release v${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
# Upload Preview ZIP
- name: Upload Preview ZIP
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./zendesk_app/preview.zip
asset_name: preview.zip
asset_content_type: application/zip
# Upload Production ZIP
- name: Upload Production ZIP
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./zendesk_app/production.zip
asset_name: production.zip
asset_content_type: application/zip