ci: add release workflow
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
name: Release VSIX
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
releases: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- run: npm run build
|
||||
|
||||
- run: npm run package
|
||||
|
||||
- name: Upload VSIX to release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
GITEA_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -e
|
||||
TAG="${GITHUB_REF#refs/tags/}"
|
||||
VSIX=$(ls *.vsix | head -1)
|
||||
API="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}"
|
||||
|
||||
echo "Creating release for tag: $TAG"
|
||||
BODY=$(jq -n --arg tag "$TAG" '{tag_name: $tag, name: $tag}')
|
||||
|
||||
RESP=$(curl -s -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$BODY" \
|
||||
"${API}/releases") || true
|
||||
|
||||
RELEASE_ID=$(echo "$RESP" | jq -r '.id // empty')
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "Release may already exist, fetching..."
|
||||
RELEASE_ID=$(curl -s \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/releases/tags/${TAG}" | jq -r '.id')
|
||||
fi
|
||||
|
||||
echo "Uploading $VSIX to release $RELEASE_ID"
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@${VSIX}" \
|
||||
"${API}/releases/${RELEASE_ID}/assets"
|
||||
|
||||
echo "Done"
|
||||
Reference in New Issue
Block a user