-
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (113 loc) · 3.9 KB
/
build_deploy.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
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
name: Build and Deploy
on:
- push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
packages: write
attestations: write
id-token: write
steps:
# Prepare Job
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.7
# Create Tag Semver
- name: Get the current branch name
id: get_branch
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Find related PR
id: find_pr
run: |
PR_URL=$(gh pr list --base ${{ env.branch }} --state=all --json url --limit=1 --jq '.[0].url')
echo "pr_url=$PR_URL" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch PR labels
id: get_labels
if: env.pr_url != ''
run: |
LABELS=$(gh pr view ${{ env.pr_url }} --json labels --jq '.labels | map(.name) | join(",")')
echo "labels=$LABELS" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set default version incrementer
run: echo "versionIncrementer=incrementPatch" >> $GITHUB_ENV
- name: Check for enhancement / breaking-change labels
if: env.labels != ''
run: |
LABELS="${{ env.labels }}"
if [[ $LABELS == *"enhancement"* ]]; then
echo "versionIncrementer=incrementMinor" >> $GITHUB_ENV
fi
if [[ $LABELS == *"breaking-change"* ]]; then
echo "versionIncrementer=incrementMajor" >> $GITHUB_ENV
fi
- name: Display Version Incrementer
run: echo "Version Incrementer == ${{ env.versionIncrementer }}"
- name: Create Tag
if: |
github.ref == 'refs/heads/main' &&
github.repository == 'isontheline/vscode-sysmon'
run: gradle createRelease -Prelease.versionIncrementer=${{ env.versionIncrementer }}
# Set Project Version
- name: Set Project Version
run: npm version from-git --no-git-tag-version
# Build Project
- name: Build Project
run: |
npm install
npm run vscode:prepublish
npm run package
# Publish to Visual Studio Marketplace
- name: Publish to Visual Studio Marketplace
if: |
github.ref == 'refs/heads/main' &&
github.repository == 'isontheline/vscode-sysmon'
uses: HaaLeo/publish-vscode-extension@v1
id: publishToMarketplace
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
# Publish to Open VSX Registry
- name: Publish to Open VSX Registry
if: |
github.ref == 'refs/heads/main' &&
github.repository == 'isontheline/vscode-sysmon'
uses: HaaLeo/publish-vscode-extension@v1
with:
extensionFile: ${{ steps.publishToMarketplace.outputs.vsixPath }}
pat: ${{ secrets.OPEN_VSX_TOKEN }}
# Push Tag
- name: Push Tag
if: |
github.ref == 'refs/heads/main' &&
github.repository == 'isontheline/vscode-sysmon'
run: gradle pushRelease
# Create Release
- name: Create release
if: |
github.ref == 'refs/heads/main' &&
github.repository == 'isontheline/vscode-sysmon'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag=$(git describe --tags --abbrev=0)
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="v${tag#v}" \
--generate-notes