-
Notifications
You must be signed in to change notification settings - Fork 18
131 lines (113 loc) · 5.03 KB
/
ci.yml
File metadata and controls
131 lines (113 loc) · 5.03 KB
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
122
123
124
125
126
127
128
129
130
131
name: Continuous Integration
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
# See: https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012
push:
branches:
- main*
pull_request:
branches:
- main*
env:
artifact-retention-days: 14
retention-comment: This comment will be **updated** with the data of the **last successful** build of this PR.
jobs:
build:
name: Full Build (node ${{ matrix.node_version }})
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
strategy:
matrix:
node_version:
- 24.x
# https://stackoverflow.com/questions/61070925/github-actions-disable-auto-cancel-when-job-fails
fail-fast: false
steps:
# using `v1` because of: https://github.com/actions/checkout/issues/246
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1
with:
# See: https://github.com/changesets/action/issues/187#issuecomment-1228413850
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: ${{ matrix.node_version }}
- name: Setup pnpm
# pnpm version from package.json `packageManager` field is used
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run ci
- name: ChangeSets Release or PR creation
id: changesets_release_or_pr
uses: changesets/action@v1
# Changesets + `apps` may automatically create tags for 'apps' during PR builds, but this should only happen
# after merge to master
# - https://github.com/changesets/changesets/blob/main/docs/versioning-apps.md
# - Our `private:true` packages (mainly VSIX) are treated as `apps` by changesets
if: github.event_name != 'pull_request'
with:
title: "chore: version packages"
commit: "chore: version packages"
version: pnpm run ci:version
publish: pnpm run ci:release
env:
# See: https://github.com/changesets/action/issues/187#issuecomment-1228413850
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
# To avoid race condition errors in the upload vsix step
- name: Wait for GH Releases to be published
if: steps.changesets_release_or_pr.outputs.published == 'true'
run: sleep 10s
shell: bash
- name: Upload VSIX to releases
run: node scripts/upload-vsix-to-releases.mjs
if: steps.changesets_release_or_pr.outputs.published == 'true'
env:
PKG_LIST: ${{steps.changesets_release_or_pr.outputs.publishedPackages}}
# because this is a **secret** it is not automatically passed in the env,
# unless explicitly defined...
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
- name: upload build artifacts
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
id: upload_build_artifacts
with:
name: all-vsix
path: packages/*/*.vsix
# default is 90 days; however, we want to avoid excessive storage usage...
retention-days: ${{ env.artifact-retention-days }}
- name: Find PR Comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3
if: github.event_name == 'pull_request'
id: find-pr-comment
with:
issue-number: ${{ github.event.number }}
comment-author: "github-actions[bot]"
body-includes: ${{ env.retention-comment }}
- name: Create / Update PR Comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
if: github.event_name == 'pull_request'
env:
HEAD_SHA: ${{ github.sha }}
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
ARTIFACT_ID: ${{ steps.upload_build_artifacts.outputs.artifact-id }}
with:
edit-mode: replace
issue-number: ${{ github.event.number }}
comment-id: ${{ steps.find-pr-comment.outputs.comment-id }}
body: |
## Build Report
[![badge]]($JOB_PATH)
Please note:
1. Files only stay for around ${{ env.artifact-retention-days }} days!
2. ${{ env.retention-comment }}
| Name | Link |
|------------|--------------------------------------------------------|
| Commit | ${{ env.HEAD_SHA }} |
| Logs | ${{ env.JOB_PATH }} |
| VSIX Files | ${{ env.JOB_PATH }}/artifacts/${{ env.ARTIFACT_ID }} |
[badge]: https://img.shields.io/badge/Build-Success!-3fb950?logo=github&style=for-the-badge