-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (72 loc) · 2.65 KB
/
publish-extension.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
name: Publish VS Code Extension
# Allow manual triggers
on:
workflow_dispatch:
inputs:
release_type:
description: "Release type: minor or major (default: patch)"
required: false
default: "patch" # Default to patch if not provided
permissions:
contents: write
pull-requests: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout repository
uses: actions/checkout@v4
# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
# Step 3: Install dependencies
- name: Install dependencies
run: npm install
# Step 4: Install vsce CLI globally
- name: Install vsce CLI
run: npm install -g @vscode/vsce
# Step 5: Verify the VSCE_TOKEN
- name: Test the VSCE_TOKEN
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
run: |
vsce verify-pat -p ${VSCE_PAT}
echo ${{ github.event.inputs.release_type }}
# Step 6: Publish and get new version number
- name: Publish to VS Code Marketplace
id: publish
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
BRANCH_NAME="vsce-version-bump" # Initial branch name before bump
git checkout -b $BRANCH_NAME
vsce publish ${{ github.event.inputs.release_type }} -p ${VSCE_PAT}
NEW_VERSION=$(grep -m1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)" package.json)
BRANCH_NAME=vsce-version-bump-${NEW_VERSION}
git branch -m $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
# Step 7: Package the extension to a .vsix file
- name: Package extension
run: vsce package
# Step 8: Upload the packaged .vsix file as an artifact
- name: Upload .vsix as artifact
uses: actions/upload-artifact@v4
with:
name: eetasks-${new_version}
path: "*.vsix"
# Step 9: Create and merge pull request with the commit made by vsce
- name: Update repository
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH_NAME="vsce-version-bump-${{ env.new_version }}"
gh pr create --title "Version bump to ${{ env.new_version}}" --body "Version bump to ${{ env.new_version }}" --base main --head $BRANCH_NAME
gh pr merge --admin --merge --delete-branch --auto
# TODO: create a draft release and upload the .vsix to it..