-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (118 loc) · 5.08 KB
/
build.yml
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Build
# NOTE: Keep this file compatible for building the last tagged release.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_call
# NOTE: Payload is the same as the caller.
# run-name is not used when on a workflow_call
run-name: "${{ github.workflow }} ${{ github.event.repository.name }}: ('${{ github.job || github.event_name }}' -> '${{ github.workflow }}') [ref: ${{ github.ref_name }}]"
on:
# Context is inherited from caller (except github.job).
# External caller (from another repo) github.ref would not be valid.
# Note: inputs from this workflow gets added to caller event inputs
workflow_call:
# Allows you to run this workflow manually from the Actions tab (for manual builds)
workflow_dispatch:
permissions:
contents: read
jobs:
# Build vscode extension with formatter_server native daemons
build_extension:
name: "Build Dart Polisher VScode extension"
runs-on: ubuntu-latest
steps:
# checkout first or it deletes dir contents
# https://github.com/actions/checkout/issues/430
# Important, clean: false only works on existing git dir
- name: "Checkout local repository"
uses: actions/checkout@v3
- name: "Setup build variables"
run: |
BUILD_REF=${{ github.ref_name }}
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
echo "BUILD_REF=$BUILD_REF" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "BUILD_REF=$BUILD_REF"
echo "PACKAGE_VERSION=$PACKAGE_VERSION"
# Alternative: https://github.com/dsaltares/fetch-gh-release-asset
- name: "Download formatter_server release"
uses: robinraju/[email protected]
with:
repository: "xnfo-dart/formatter_server"
latest: true
#tag: "v1.0.0" #TODO: use tags after >1.0.0
#fileName: "dartpolishd-*.zip"
out-file-path: "bin"
- name: Rename releases files to extension format
run: |
ls -R
BIN_NAME="dartpolishd"
OS_ARRAY="linux windows mac"
for OS in $OS_ARRAY
do
unzip -o "${BIN_NAME}-$OS"
rm "${BIN_NAME}-${OS}.zip"
if [[ "$OS" == "windows" ]]; then
mv ${BIN_NAME}.exe "${BIN_NAME}-$OS.exe"
else
mv $BIN_NAME "${BIN_NAME}-$OS"
fi
done
ls -R
working-directory: bin
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install vscode package tool
run: npm install -g vsce
- name: npm install
run: npm install
- name: npm lint
run: npm run lint
# TODO: tests
# TODO: vsix architectures packages. --target to reduce download size. (use matrix strategy)
- name: vsce package
run: vsce package
- name: Store vsix
uses: actions/upload-artifact@v3
with:
name: dart-polisher-v${{ env.PACKAGE_VERSION }}-vsix
path: "*.vsix"
retention-days: 5
- name: Generate release data using Markdown
run: |
echo '### Build' >> $GITHUB_STEP_SUMMARY
echo 'Built from git ref: `${{ env.BUILD_REF }}`' >> $GITHUB_STEP_SUMMARY
printf 'Build package version:\n```\n${{ env.PACKAGE_VERSION }}\n```\n' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '### Workflow (Data)' >> $GITHUB_STEP_SUMMARY
echo 'Event: `${{ github.event_name }}`' >> $GITHUB_STEP_SUMMARY
echo 'REF: `${{ github.ref_type }} : ${{ github.ref }}`' >> $GITHUB_STEP_SUMMARY
echo 'SHA: ${{ env.GITHUB_SHA }}' >> $GITHUB_STEP_SUMMARY
echo 'File: `build.yml`' >> $GITHUB_STEP_SUMMARY
echo 'Repository: `xnfo-dart/dart-polisher-vscode`' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '#### Workflow (Called from)' >> $GITHUB_STEP_SUMMARY
echo 'Workflow name: `${{ github.workflow }}`' >> $GITHUB_STEP_SUMMARY
echo 'Workflow file: `${{ github.event.workflow }}`' >> $GITHUB_STEP_SUMMARY
echo 'Repository: `${{ github.repository }}`' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '#### Inputs' >> $GITHUB_STEP_SUMMARY
printf 'Inputs:\n```json\n${{ toJSON(inputs) }}\n```\n' >> $GITHUB_STEP_SUMMARY
printf 'Inputs: (Caller)\n```json\n${{ toJSON(github.event.inputs) }}\n```\n' >> $GITHUB_STEP_SUMMARY
shell: bash
- name: Setup build data
run: |
mkdir -p ./build-data
echo '${{ env.BUILD_REF }}' >> ./build-data/ref
echo '${{ env.PACKAGE_VERSION }}' >> ./build-data/package_version
- name: Upload build data
uses: actions/upload-artifact@v3
with:
name: extension-build-data
path: build-data/
retention-days: 5
# delete temporary artifacts
# - uses: geekyeggo/delete-artifact@v2
# with:
# name: |
# native-executables