forked from vivaxy/vscode-conventional-commits
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (92 loc) · 3.27 KB
/
Copy pathbuild.yml
File metadata and controls
106 lines (92 loc) · 3.27 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
name: build
on:
push:
branches:
- master
paths:
- "src/**"
workflow_dispatch:
pull_request:
types: [labeled]
jobs:
build:
name: Build beta extension
runs-on: ubuntu-latest
if: >
contains('push,workflow_dispatch', github.event_name) ||
contains(github.event.pull_request.labels.*.name, 'wait-to-build')
outputs:
extension_name: ${{steps.version.outputs.repo}}-${{steps.version.outputs.beta}}.vsix
steps:
- name: Checkout code
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- name: Setup nodejs
uses: actions/setup-node@v3.6.0
with:
node-version: 14
- name: Setup package
run: yarn install
- name: Bump version
run: |
yarn standard-version --skip.changelog --skip.commit --skip.tag
- name: Generate name for artifact
uses: actions/github-script@v6.4.0
id: version
with:
result-encoding: string
script: |
core.setOutput('repo', context.repo.repo);
core.setOutput('beta', process.env.GITHUB_SHA.slice(0,7));
- name: Edit version for building
env:
SUFFIX: ${{steps.version.outputs.beta}}
run: |
sed -r 's/"version": "(.*)"/"version": "\1-${{ env.SUFFIX }}"/' -i package.json
- name: Build artifact
run: yarn build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{steps.version.outputs.repo}}-${{steps.version.outputs.beta}}.vsix
path: "*.vsix"
output:
name: Output PR information
needs: build
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Generate PR number
if: ${{ github.event_name == 'pull_request' }}
id: PR
run: |
mkdir -p ./pr
printf ${{ github.event.number }} > ./pr/NR
- name: Generate PR label name
if: contains(github.event.pull_request.labels.*.name, 'wait-to-build')
run: |
printf 'wait-to-build' > ./pr/label
echo "pr_build=true" >> $GITHUB_ENV
- name: Generate PR comment if success
if: ${{ env.pr_build == 'true' && needs.build.result == 'success' }}
env:
WORKFLOW_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
name: ${{ needs.build.outputs.extension_name }}
run: |
printf "The beta extension of this pull has been built in the workflow! 🎉\n" >> ./pr/comment
printf "Download \`${{env.name}}\` " >> ./pr/comment
printf "in [artifacts](${{env.WORKFLOW_URL}}#artifacts). 🚀" >> ./pr/comment
- name: Generate PR comment if happening other conditions
if: ${{ env.pr_build == 'true' && needs.build.result != 'success' }}
env:
WORKFLOW_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
run: |
printf "Oops, The build workflow has failed! See in " >> ./pr/comment
printf "[summary](${{env.WORKFLOW_URL}}#annotations). 😥" >> ./pr/comment
- name: Upload the PR information
uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' }}
with:
name: pr
path: pr/