Skip to content

Commit 186b04c

Browse files
authored
build: update extension to use node 20 (#7)
1 parent a384682 commit 186b04c

File tree

8 files changed

+337
-648
lines changed

8 files changed

+337
-648
lines changed

.github/workflows/ci-pull-request.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Check extension
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: '20'
23+
24+
- name: Install tfx-cli and typescript
25+
run: |
26+
npm install -g tfx-cli
27+
npm install -g typescript
28+
29+
- name: Login to Azure DevOps
30+
uses: azure/login@v2
31+
with:
32+
client-id: ${{ secrets.AZURE_APPLICATION_CLIENT_ID }}
33+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
34+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
35+
36+
- name: Get Azure DevOps access token
37+
id: devops_token
38+
run: |
39+
TOKEN="$(az account get-access-token --resource "${{ secrets.AZURE_MARKETPLACE_ACCESS_SCOPE }}" --query accessToken -o tsv)"
40+
echo "::add-mask::$TOKEN"
41+
echo "azure_devops_access_token=$TOKEN" >> "$GITHUB_OUTPUT"
42+
43+
- name: Build release
44+
run: |
45+
make build
46+
47+
- name: Increment version
48+
id: bump
49+
run: |
50+
chmod +x ./bump_version.sh
51+
NEW_VERSION="$(./bump_version.sh)"
52+
if [[ -z "$NEW_VERSION" ]]; then
53+
echo "Version bump script returned empty version" >&2
54+
exit 1
55+
fi
56+
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"

.github/workflows/main.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ permissions:
99
contents: write
1010
id-token: write
1111

12+
concurrency:
13+
group: release-${{ github.ref }}
14+
cancel-in-progress: true
15+
1216
jobs:
1317
build:
1418
runs-on: ubuntu-latest
@@ -20,48 +24,66 @@ jobs:
2024
- name: Setup Node.js
2125
uses: actions/setup-node@v2
2226
with:
23-
node-version: '14'
27+
node-version: '20'
2428

2529
- name: Install tfx-cli and typescript
2630
run: |
2731
npm install -g tfx-cli
2832
npm install -g typescript
2933
3034
- name: Login to Azure DevOps
31-
uses: azure/login@v1
35+
uses: azure/login@v2
3236
with:
3337
client-id: ${{ secrets.AZURE_APPLICATION_CLIENT_ID }}
3438
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
3539
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
3640

3741
- name: Get Azure DevOps access token
38-
id: get_token
42+
id: devops_token
3943
run: |
40-
echo "AZURE_DEVOPS_ACCESS_TOKEN=$(az account get-access-token --resource ${{ secrets.AZURE_MARKETPLACE_ACCESS_SCOPE }} --query accessToken -o tsv)" >> $GITHUB_ENV
44+
TOKEN="$(az account get-access-token --resource "${{ secrets.AZURE_MARKETPLACE_ACCESS_SCOPE }}" --query accessToken -o tsv)"
45+
echo "::add-mask::$TOKEN"
46+
echo "azure_devops_access_token=$TOKEN" >> "$GITHUB_OUTPUT"
4147
4248
- name: Build release
4349
run: |
4450
make build
4551
4652
- name: Increment version
53+
id: bump
4754
run: |
4855
chmod +x ./bump_version.sh
49-
NEW_VERSION=$(./bump_version.sh)
50-
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
56+
NEW_VERSION="$(./bump_version.sh)"
57+
if [[ -z "$NEW_VERSION" ]]; then
58+
echo "Version bump script returned empty version" >&2
59+
exit 1
60+
fi
61+
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
5162
5263
- name: Publish release
5364
env:
54-
AZURE_DEVOPS_ACCESS_TOKEN: ${{ env.AZURE_DEVOPS_ACCESS_TOKEN }}
65+
AZURE_DEVOPS_ACCESS_TOKEN: ${{ steps.devops_token.outputs.azure_devops_access_token }}
5566
run: |
5667
make publish-release
5768
5869
- name: Commit version increment
5970
run: |
6071
git config --local user.email "action@github.com"
6172
git config --local user.name "GitHub Action"
62-
git add ./sysdig-cli-scan-task/task.json
63-
git add ./VERSION
64-
git add ./vss-extension.json
65-
git commit -m "Increment version to ${{ env.NEW_VERSION }}"
66-
git tag ${{ env.NEW_VERSION }}
67-
git push origin HEAD --tags
73+
74+
git add ./sysdig-cli-scan-task/task.json ./VERSION ./vss-extension.json
75+
if git diff --cached --quiet; then
76+
echo "No changes to commit."
77+
exit 0
78+
fi
79+
80+
VERSION="${{ steps.bump.outputs.new_version }}"
81+
git commit -m "chore: bump version to ${VERSION}"
82+
if git tag -l "${VERSION}" | grep -q "^${VERSION}$"; then
83+
echo "Tag ${VERSION} already exists, skipping tag creation."
84+
else
85+
git tag -a "${VERSION}" -m "Release ${VERSION}"
86+
fi
87+
88+
git push origin HEAD
89+
git push origin "${VERSION}"

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ AZURE_DEVOPS_ACCESS_TOKEN ?=
66
all: build
77

88
build:
9-
npm install
10-
cd $(TYPESCRIPT_SOURCE) && npm install && tsc
9+
npm ci
10+
cd $(TYPESCRIPT_SOURCE) && npm ci && tsc
1111

1212
publish-local: build
1313
tfx extension publish \

package-lock.json

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)