-
Notifications
You must be signed in to change notification settings - Fork 10
171 lines (151 loc) · 7.2 KB
/
release-dev.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
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
169
170
171
name: CI/CD Pipeline for Development Release.
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
packages: write
checks: write
pull-requests: write
jobs:
test:
uses: ./.github/workflows/test.yml
release-dev:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20.15.1
# Cache root dependencies - only reuse if package-lock.json exactly matches
- name: Cache root dependencies
uses: actions/cache@v4
id: root-cache
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
# Cache webview-ui dependencies - only reuse if package-lock.json exactly matches
- name: Cache webview-ui dependencies
uses: actions/cache@v4
id: webview-cache
with:
path: webview-ui/node_modules
key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }}
- name: Install root dependencies
if: steps.root-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Install webview-ui dependencies
if: steps.webview-cache.outputs.cache-hit != 'true'
run: cd webview-ui && npm ci
- name: Build package
run: |
# Set the package name and version from package.json or use default values
PACKAGE_NAME="$(node -p "require('./package.json').name || 'hai-build-code-generator'")"
BUILD_VERSION="$(node -p "require('./package.json').version || '0.0.0'")"
# Save the environment variables to GitHub Actions environment
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
# Build the VSIX package
echo "Output Package Name: $PACKAGE_NAME-$BUILD_VERSION.vsix"
npx @vscode/vsce package --out "$PACKAGE_NAME-$BUILD_VERSION.vsix"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: "${{ env.PACKAGE_NAME }}-${{ env.BUILD_VERSION }}"
path: "${{ env.PACKAGE_NAME }}-${{ env.BUILD_VERSION }}.vsix"
retention-days: 90
- name: Notify release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTIFICATION_URL: ${{ secrets.NOTIFICATION_URL }}
run: |
ARTIFACT_ID=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --header "authorization: Bearer $GITHUB_TOKEN" | jq -r '.artifacts[0].id')
if [[ -z "$ARTIFACT_ID" || "$ARTIFACT_ID" == "null" ]]; then
echo "❌ ERROR: ARTIFACT_ID is missing or invalid."
exit 1
fi
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${ARTIFACT_ID}"
echo "✅ Artifact URL: $ARTIFACT_URL"
if [[ -z "$NOTIFICATION_URL" ]]; then
echo "❌ ERROR: NOTIFICATION_URL is not set."
exit 1
fi
# Fetch random celebration GIF
RANDOM_GIF=$(curl -s "https://api.giphy.com/v1/gifs/random?api_key=0UTRbFtkMxAplrohufYco5IY74U8hOes&tag=celebration+sports&rating=g" | jq -r '.data.images.original.webp')
echo "Notifying release ${{ needs.initialize.outputs.package_name }}:${{ needs.initialize.outputs.build_version }}"
# Prepare the notification with UI components
curl -X POST -H 'Content-type: application/json' --data "{
\"type\": \"message\",
\"attachments\": [
{
\"contentType\": \"application/vnd.microsoft.card.adaptive\",
\"content\": {
\"type\": \"AdaptiveCard\",
\"version\": \"1.5\",
\"body\": [
{
\"type\": \"ColumnSet\",
\"columns\": [
{
\"type\": \"Column\",
\"width\": \"auto\",
\"items\": [
{
\"type\": \"Icon\",
\"name\": \"Megaphone\",
\"size\": \"xxSmall\",
\"color\": \"Accent\",
\"style\": \"Filled\"
}
]
},
{
\"type\": \"Column\",
\"width\": \"stretch\",
\"items\": [
{
\"type\": \"TextBlock\",
\"text\": \"Release Announcement\",
\"size\": \"Small\",
\"isSubtle\": true
}
]
}
]
},
{
\"type\": \"TextBlock\",
\"text\": \"Release - v${{ env.BUILD_VERSION }}\",
\"weight\": \"Bolder\",
\"size\": \"Medium\"
},
{
\"type\": \"TextBlock\",
\"text\": \"🎉 The latest release is now available!\",
\"wrap\": true
},
{
\"type\": \"Image\",
\"url\": \"$RANDOM_GIF\",
\"size\": \"Stretch\"
},
{
\"type\": \"ActionSet\",
\"actions\": [
{
\"type\": \"Action.OpenUrl\",
\"title\": \"Download Artifact\",
\"url\": \"$ARTIFACT_URL\",
\"iconUrl\": \"icon:ArrowDownload\"
}
]
}
]
}
}
]
}" $NOTIFICATION_URL