Skip to content

Commit 66976d2

Browse files
author
amvanbaren
committed
Use separate jobs instead of child_process
1 parent f7732c6 commit 66976d2

File tree

8 files changed

+512
-238
lines changed

8 files changed

+512
-238
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Publish extension
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
extension:
6+
description: Extension JSON object
7+
required: true
8+
type: string
9+
publishContext:
10+
description: Publish context JSON object
11+
required: true
12+
type: string
13+
skipPublish:
14+
description: Skip publishing to Open VSX, only build extensions
15+
required: true
16+
type: boolean
17+
force:
18+
description: Force publish to Open VSX, even if version is already published
19+
required: true
20+
type: boolean
21+
jobs:
22+
download_release:
23+
name: Download latest release
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
env:
28+
DO_DOWNLOAD: ${{ fromJSON(inputs.publishContext).files != null }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
if: ${{ env.DO_DOWNLOAD == 'true' }}
32+
- uses: actions/[email protected]
33+
if: ${{ env.DO_DOWNLOAD == 'true' }}
34+
with:
35+
node-version: "20.x"
36+
- run: npm install
37+
if: ${{ env.DO_DOWNLOAD == 'true' }}
38+
- run: npm i -g @vscode/vsce pnpm
39+
if: ${{ env.DO_DOWNLOAD == 'true' }}
40+
- id: download_extension
41+
uses: actions/github-script@v7
42+
if: ${{ env.DO_DOWNLOAD == 'true' }}
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
EXTENSION: ${{ inputs.extension }}
46+
PUBLISH_CONTEXT: ${{ inputs.publishContext }}
47+
with:
48+
script: |
49+
const script = require('./scripts/download-extension.js');
50+
await script();
51+
build_extension:
52+
name: Build Extension
53+
runs-on: ubuntu-latest
54+
needs: download_release
55+
permissions:
56+
actions: none
57+
steps:
58+
- uses: actions/checkout@v4
59+
- uses: actions/[email protected]
60+
with:
61+
node-version: "20.x"
62+
- uses: oven-sh/setup-bun@v2
63+
with:
64+
bun-version: latest
65+
- name: Set up pyenv
66+
uses: "gabrielfalcao/pyenv-action@32ef4d2c861170ce17ded56d10329d83f4c8f797"
67+
with:
68+
command: python --version
69+
- name: Set default global version
70+
run: |
71+
pyenv install 3.8
72+
pyenv global 3.8
73+
- uses: actions/setup-java@v4
74+
with:
75+
distribution: "microsoft"
76+
java-version: "21"
77+
- name: Install dependencies for native modules
78+
run: |
79+
sudo apt-get update
80+
sudo apt-get install libpango1.0-dev libgif-dev
81+
- run: npm install
82+
- run: npm i -g @vscode/vsce pnpm
83+
- uses: actions/download-artifact@v4
84+
with:
85+
path: /tmp
86+
- id: build_extension
87+
name: Build extension
88+
uses: actions/github-script@v7
89+
env:
90+
FORCE: ${{ inputs.force }}
91+
SKIP_PUBLISH: ${{ inputs.skipPublish }}
92+
EXTENSION: ${{ inputs.extension }}
93+
PUBLISH_CONTEXT: ${{inputs.publishContext}}
94+
with:
95+
script: |
96+
const script = require('./scripts/build-extension.js');
97+
await script({core});
98+
outputs:
99+
extensionFiles: ${{ steps.build_extension.outputs.extensionFiles }}
100+
publish_extension:
101+
name: Publish Extension
102+
runs-on: ubuntu-latest
103+
if: ${{ inputs.skipPublish != 'true' }}
104+
needs: build_extension
105+
permissions:
106+
actions: none
107+
steps:
108+
- uses: actions/checkout@v4
109+
- uses: actions/[email protected]
110+
with:
111+
node-version: "20.x"
112+
- run: npm install
113+
- run: npm i -g @vscode/vsce pnpm
114+
- uses: actions/download-artifact@v4
115+
with:
116+
path: /tmp
117+
- uses: actions/github-script@v7
118+
env:
119+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
120+
EXTENSION_ID: ${{ fromJson(inputs.extension).id }}
121+
EXTENSION_FILES: ${{needs.build_extension.outputs.extensionFiles}}
122+
with:
123+
script: |
124+
const script = require('./scripts/publish-extension.js');
125+
await script();

.github/workflows/publish-extensions.yml

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -29,67 +29,58 @@ jobs:
2929
FORCE: ${{ github.event.inputs.forcefullyPublish }}
3030
name: Publish Extensions
3131
runs-on: ubuntu-latest
32+
permissions:
33+
actions: write
34+
contents: read
3235
steps:
3336
- uses: actions/checkout@v4
3437
- uses: actions/[email protected]
3538
with:
3639
node-version: "20.x"
37-
- uses: oven-sh/setup-bun@v2
38-
with:
39-
bun-version: latest
40-
- name: Set up pyenv
41-
uses: "gabrielfalcao/pyenv-action@32ef4d2c861170ce17ded56d10329d83f4c8f797"
42-
with:
43-
command: python --version
44-
- name: Set default global version
45-
run: |
46-
pyenv install 3.8
47-
pyenv global 3.8
48-
- uses: actions/setup-java@v4
49-
with:
50-
distribution: "microsoft"
51-
java-version: "21"
52-
- name: Install dependencies for native modules
53-
run: |
54-
sudo apt-get update
55-
sudo apt-get install libpango1.0-dev libgif-dev
5640
- run: npm install
5741
- run: npm i -g @vscode/vsce pnpm
58-
- run: node publish-extensions
42+
- uses: actions/github-script@v7
5943
env:
60-
OVSX_PAT: ${{ secrets.OVSX_PAT }}
6144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
- name: Report results
63-
run: bun run ./report-extensions.ts
64-
- uses: actions/upload-artifact@v4
65-
if: always()
45+
REPOSITORY: ${{ github.repository }}
6646
with:
67-
name: report
68-
path: |
69-
/tmp/stat.json
70-
/tmp/result.md
71-
- uses: actions/upload-artifact@v4
72-
if: always()
73-
with:
74-
name: artifacts
75-
path: |
76-
/tmp/artifacts/*.vsix
77-
- name: Upload job summary
78-
if: always()
79-
run: cat /tmp/result.md >> $GITHUB_STEP_SUMMARY
80-
- name: Get previous job's status
81-
id: lastrun
82-
uses: filiptronicek/get-last-job-status@main
83-
- name: Slack Notification
84-
if: ${{ !github.event.inputs.extensions && ((success() && steps.lastrun.outputs.status == 'failed') || failure()) }}
85-
uses: rtCamp/action-slack-notify@v2
86-
env:
87-
SLACK_WEBHOOK: ${{ secrets.GITPOD_SLACK_WEBHOOK }}
88-
SLACK_COLOR: ${{ job.status }}
47+
script: |
48+
const script = require('./scripts/publish-extensions.js');
49+
await script({github});
50+
# TODO fix reporting
51+
# - name: Report results
52+
# run: bun run ./report-extensions.ts
53+
# - uses: actions/upload-artifact@v4
54+
# if: always()
55+
# with:
56+
# name: report
57+
# path: |
58+
# /tmp/stat.json
59+
# /tmp/result.md
60+
# - uses: actions/upload-artifact@v4
61+
# if: always()
62+
# with:
63+
# name: artifacts
64+
# path: |
65+
# /tmp/artifacts/*.vsix
66+
# - name: Upload job summary
67+
# if: always()
68+
# run: cat /tmp/result.md >> $GITHUB_STEP_SUMMARY
69+
# - name: Get previous job's status
70+
# id: lastrun
71+
# uses: filiptronicek/get-last-job-status@main
72+
# - name: Slack Notification
73+
# if: ${{ !github.event.inputs.extensions && ((success() && steps.lastrun.outputs.status == 'failed') || failure()) }}
74+
# uses: rtCamp/action-slack-notify@v2
75+
# env:
76+
# SLACK_WEBHOOK: ${{ secrets.GITPOD_SLACK_WEBHOOK }}
77+
# SLACK_COLOR: ${{ job.status }}
8978
check_parity:
9079
name: Check MS parity
9180
runs-on: ubuntu-latest
9281
needs: publish_extensions
82+
permissions:
83+
actions: none
9384
if: ${{ !github.event.inputs.extensions }} # only run on full runs
9485
steps:
9586
- uses: actions/checkout@v4

.github/workflows/validate-pr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ jobs:
3030
run: |
3131
pyenv install 3.8
3232
pyenv global 3.8
33-
- run: EXTENSIONS=$(node diff-extensions) node publish-extensions
33+
- run: echo "EXTENSIONS=$(node diff-extensions)" >> $GITHUB_ENV
34+
- uses: actions/github-script@v7
3435
env:
3536
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
REPOSITORY: ${{ github.repository }}
38+
with:
39+
script: |
40+
const script = require('./scripts/publish-extensions.js');
41+
await script({github});
3642
- name: Report results
3743
run: bun run ./report-extensions.ts
3844
- uses: actions/upload-artifact@v4

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"format": "prettier --write ."
2929
},
3030
"dependencies": {
31+
"@actions/artifact": "^2.3.2",
3132
"@vscode/vsce": "^3.0.0",
3233
"ajv": "^8.8.1",
3334
"chai": "^5.1.0",
@@ -41,12 +42,17 @@
4142
"octokit": "^3.1.2",
4243
"ovsx": "latest",
4344
"prettier": "^3.2.5",
44-
"semver": "^7.1.3"
45+
"semver": "^7.1.3",
46+
"xml2js": "^0.6.2",
47+
"yauzl-promise": "^4.0.0"
4548
},
4649
"devDependencies": {
50+
"@actions/github-script": "github:actions/github-script",
4751
"@types/human-number": "^1.0.0",
4852
"@types/node": "^22.2.0",
4953
"@types/unzipper": "^0.10.5",
54+
"@types/xml2js": "^0.4.14",
55+
"@types/yauzl-promise": "^4.0.1",
5056
"bun-types": "^1.0.1"
5157
}
5258
}

0 commit comments

Comments
 (0)