-
-
Notifications
You must be signed in to change notification settings - Fork 6
74 lines (64 loc) · 2.29 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
name: Build IITC Button
# read-only repo token
# no access to secrets
on:
push:
branches:
- master
tags:
- '*'
pull_request:
paths-ignore:
- '!.github/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Linter
run: npm run lint
- name: Build
run: npm run build
- name: Get version from package.json
if: startsWith(github.ref, 'refs/tags/v')
uses: polyseam/get-version-key-from-json@v1.0.0
id: get-version-key-from-json
with:
path-to-json: './package.json'
- name: Save metadata
run: |
mkdir -p ./build/.metadata
if [ "$GITHUB_EVENT_NAME" = "push" ]; then
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then
mv artifacts/*.zip ./build/iitc-button-${{steps.get-version-key-from-json.outputs.version}}.zip
echo "release" > ./build/.metadata/build_type
else
# Beta build from master branch
mv artifacts/*.zip ./build/iitc-button-${{github.sha}}.zip
echo "beta" > ./build/.metadata/build_type
fi
echo ${{ github.sha }} > ./build/.metadata/commit
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
mv artifacts/*.zip ./build/iitc-button-${{github.event.pull_request.head.sha}}.zip
echo "PR" > ./build/.metadata/build_type
echo ${{ github.event.pull_request.head.sha }} > ./build/.metadata/commit
fi
echo $( ls ./build/ | grep '.zip' ) > ./build/.metadata/zip_filename
echo "GITHUB_SHA_SHORT=$(cat ./build/.metadata/commit | cut -c 1-6)" >> $GITHUB_ENV
- uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "./build/iitc-button-${{ steps.get-version-key-from-json.outputs.version }}.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v2
with:
name: iitc-button-${{ env.GITHUB_SHA_SHORT }}-artifact
path: |
./build/