|
1 | | -name: Release new version |
| 1 | +name: Release and publish extension |
| 2 | + |
| 3 | +run-name: Release v${{ github.event.inputs.version }} |
2 | 4 |
|
3 | 5 | on: |
4 | 6 | workflow_dispatch: |
|
8 | 10 | description: "Version to bump `package.json` to (format: x.y.z)" |
9 | 11 |
|
10 | 12 | jobs: |
11 | | - build: |
| 13 | + release: |
12 | 14 | runs-on: ubuntu-latest |
13 | 15 |
|
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + |
14 | 19 | steps: |
15 | | - - uses: actions/checkout@v2 |
16 | | - - run: | |
17 | | - git config --global user.email "[email protected]" |
18 | | - git config --global user.name "Christopher Schleiden" |
19 | | - - uses: actions/setup-node@v2 |
| 20 | + - uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - uses: actions/setup-node@v3 |
20 | 23 | with: |
21 | | - node-version: "12" |
22 | | - - run: npm version ${{ github.event.inputs.version }} |
23 | | - - run: npm install |
| 24 | + node-version: "16" |
| 25 | + |
| 26 | + - name: Bump version and push |
| 27 | + run: | |
| 28 | + git config --global user.email "[email protected]" |
| 29 | + git config --global user.name "GitHub Actions" |
| 30 | +
|
| 31 | + npm version ${{ github.event.inputs.version }} --no-git-tag-version |
| 32 | + git add package.json package-lock.json |
| 33 | + git commit -m "Release extension version ${{ github.event.inputs.version }}" |
| 34 | +
|
| 35 | + git push |
| 36 | +
|
| 37 | + - run: npm ci |
24 | 38 | - run: npm run package |
25 | | - - name: Create Release |
26 | | - id: create_release |
27 | | - uses: actions/create-release@v1 |
28 | | - env: |
29 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + - uses: actions/upload-artifact@v3 |
30 | 41 | with: |
31 | | - tag_name: "release-v${{ github.event.inputs.version }}" |
32 | | - release_name: "v${{ github.event.inputs.version }}" |
33 | | - draft: false |
34 | | - prerelease: false |
35 | | - - name: Upload Release Asset |
36 | | - id: upload-release-asset |
37 | | - uses: actions/upload-release-asset@v1 |
38 | | - env: |
39 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + name: vscode-github-actions-${{ github.event.inputs.version }}.vsix |
| 43 | + path: ./vscode-github-actions-${{ github.event.inputs.version }}.vsix |
| 44 | + |
| 45 | + - name: Create release and upload release asset |
| 46 | + uses: actions/github-script@v6 |
40 | 47 | with: |
41 | | - upload_url: ${{ steps.create_release.outputs.upload_url }} |
42 | | - asset_path: ./vscode-github-actions-${{ github.event.inputs.version }}.vsix |
43 | | - asset_name: vscode-github-actions-${{ github.event.inputs.version }}.vsix |
44 | | - asset_content_type: application/vsix |
| 48 | + script: | |
| 49 | + const fs = require("fs"); |
| 50 | +
|
| 51 | + const release = await github.rest.repos.createRelease({ |
| 52 | + owner: context.repo.owner, |
| 53 | + repo: context.repo.repo, |
| 54 | + tag_name: "release-v${{ github.event.inputs.version }}", |
| 55 | + name: "v${{ github.event.inputs.version }}", |
| 56 | + draft: false, |
| 57 | + prerelease: false |
| 58 | + }); |
| 59 | +
|
| 60 | + const path = "./vscode-github-actions-${{ github.event.inputs.version }}.vsix"; |
| 61 | + await github.rest.repos.uploadReleaseAsset({ |
| 62 | + owner: context.repo.owner, |
| 63 | + repo: context.repo.repo, |
| 64 | + release_id: release.data.id, |
| 65 | + data: fs.readFileSync(path).toString(), |
| 66 | + name: "vscode-github-actions-${{ github.event.inputs.version }}.vsix", |
| 67 | + headers: { |
| 68 | + "content-type": "application/vsix", |
| 69 | + "content-length": fs.statSync(path).size |
| 70 | + } |
| 71 | + }); |
| 72 | +
|
| 73 | + publish: |
| 74 | + environment: publish |
| 75 | + |
| 76 | + needs: release |
| 77 | + |
| 78 | + runs-on: ubuntu-latest |
| 79 | + permissions: {} |
| 80 | + |
| 81 | + steps: |
| 82 | + - uses: actions/download-artifact@v3 |
| 83 | + with: |
| 84 | + name: vscode-github-actions-${{ github.event.inputs.version }}.vsix |
| 85 | + |
45 | 86 | - name: Publish to marketplace |
46 | | - uses: HaaLeo/publish-vscode-extension@v0 |
| 87 | + # https://github.com/HaaLeo/publish-vscode-extension/releases/tag/v1.2.0 |
| 88 | + uses: HaaLeo/publish-vscode-extension@c1a0486c5a3eed24e8c21d4e37889a7c4c60c443 |
47 | 89 | with: |
48 | 90 | pat: ${{ secrets.PUBLISHER_KEY }} |
49 | 91 | registryUrl: https://marketplace.visualstudio.com |
50 | 92 | extensionFile: ./vscode-github-actions-${{ github.event.inputs.version }}.vsix |
51 | | - packagePath: "" |
52 | | - - run: git push |
|
0 commit comments