Prepare for release v3.6.0 (#162) #74
This file contains hidden or 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: 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 |