-
Notifications
You must be signed in to change notification settings - Fork 53
167 lines (145 loc) · 7.05 KB
/
release-dev.yml
File metadata and controls
167 lines (145 loc) · 7.05 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
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"
env:
LANGFUSE_API_URL: ${{ secrets.LANGFUSE_API_URL }}
LANGFUSE_API_KEY: ${{ secrets.LANGFUSE_API_KEY }}
LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }}
POST_HOG_API_KEY: ${{ secrets.POST_HOG_API_KEY }}
POST_HOG_HOST: ${{ secrets.POST_HOG_API_URL }}
- 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_NAME="${{ env.PACKAGE_NAME }}-${{ env.BUILD_VERSION }}"
echo "Artifact name: $ARTIFACT_NAME"
ARTIFACT_ID=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --header "authorization: Bearer $GITHUB_TOKEN" | jq -r --arg NAME "$ARTIFACT_NAME" '.artifacts[] | select(.name == $NAME) | .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
echo "Notifying release ${{ needs.initialize.outputs.package_name }}:${{ needs.initialize.outputs.build_version }}"
# Get commit details
COMMIT_SHA=${{ github.sha }}
COMMIT_SHORT_SHA=${COMMIT_SHA:0:7}
# Get commit message, author and timestamp (IST - UTC+5:30)
COMMIT_MSG=$(git log -1 --pretty=format:"%s" $COMMIT_SHA)
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an" $COMMIT_SHA)
TIMESTAMP=$(TZ=":Asia/Kolkata" date "+%d-%b-%Y %I:%M %p IST")
# 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\": \"TextBlock\",
\"text\": \"✅ Development Build Successfull\",
\"weight\": \"Bolder\",
\"size\": \"Medium\"
},
{
\"type\": \"FactSet\",
\"facts\": [
{
\"title\": \"Version\",
\"value\": \"v${{ env.BUILD_VERSION }}\"
},
{
\"title\": \"Built at\",
\"value\": \"$TIMESTAMP\"
},
{
\"title\": \"Commit\",
\"value\": \"${COMMIT_SHORT_SHA} - ${COMMIT_MSG}\"
},
{
\"title\": \"Author\",
\"value\": \"$COMMIT_AUTHOR\"
}
]
},
{
\"type\": \"ActionSet\",
\"actions\": [
{
\"type\": \"Action.OpenUrl\",
\"title\": \"Download Artifact\",
\"url\": \"$ARTIFACT_URL\",
\"iconUrl\": \"icon:ArrowDownload\"
}
]
}
]
}
}
]
}" $NOTIFICATION_URL