-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (68 loc) · 2.84 KB
/
build.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
name: Package Extension
on:
push:
branches:
- main
jobs:
once:
permissions:
contents: write # for creating release
name: Create vsix
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install npm dependencies
run: npm install
- name: Get package version
id: get_package_version_ubuntu
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Get package name
id: get_package_name_ubuntu
run: echo "name=$(node -p "require('./package.json').name")" >> $GITHUB_OUTPUT
- name: Build extension
run: npm run prepackage
- name: Install vsce globally
run: npm install -g @vscode/vsce
- name: Package extension
run: vsce package --no-yarn --allow-star-activation -o .
- name: Fetch latest commit hash
id: get_commit_hash_ubuntu
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Rename and move VSIX file
id: rename_vsix_ubuntu
run: |
old_name="${{ steps.get_package_name_ubuntu.outputs.name }}-${{ steps.get_package_version_ubuntu.outputs.version }}.vsix"
new_name="${old_name%.*}-${{ steps.get_commit_hash_ubuntu.outputs.hash }}.vsix"
mkdir -p releases
mv "$old_name" "releases/$new_name"
echo "new_name=$new_name" >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_package_version_ubuntu.outputs.version }}-${{ steps.get_commit_hash_ubuntu.outputs.hash }}
release_name: ${{ steps.get_package_version_ubuntu.outputs.version }}-${{ steps.get_commit_hash_ubuntu.outputs.hash }}
body: |
Release created automatically from workflow.
draft: true
prerelease: true
- name: Upload VSIX file as release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: releases/${{ steps.rename_vsix_ubuntu.outputs.new_name }}
asset_name: ${{ steps.get_package_name_ubuntu.outputs.name }}-${{ steps.get_package_version_ubuntu.outputs.version }}-${{ steps.get_commit_hash_ubuntu.outputs.hash }}.vsix
asset_content_type: application/zip
- name: Display success message
run: echo "Extension packaging complete and release created with asset uploaded."