-
-
Notifications
You must be signed in to change notification settings - Fork 115
147 lines (130 loc) · 4.73 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
on:
push:
tags:
- '*'
branches:
- '*'
pull_request:
branches:
- '*'
# repository_dispatch is a newer github-actions feature that will allow building from triggers other than code merge/PR
repository_dispatch:
types: [build]
name: Build EmuFlight
jobs:
build:
timeout-minutes: 75
strategy:
max-parallel: 4
matrix:
targets: [targets-group-1, targets-group-2, targets-group-3, targets-group-rest]
runs-on: ubuntu-latest
steps:
# curl, by default, may timeout easily
- name: curl fix
run: function curl () { command curl --connect-timeout 30 --retry 10 "$@" ; }
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Take the trash out
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi -f $(docker image ls -aq)
sync
df -h
continue-on-error: true
- name: Setup Python
uses: actions/setup-python@v1
- name: Setup Toolchain
uses: fiam/arm-none-eabi-gcc@master
with:
release: '9-2020-q2' # The arm-none-eabi-gcc release to use.
- name: Get code version
id: get_version
run: echo "VERSION=$(make version)" >> $GITHUB_ENV
# for Makefile interaction
- name: Get GitHub Build Number (ENV)
id: get_buildno
run: echo "GITHUBBUILDNUMBER=${{ github.run_number }}" >> $GITHUB_ENV
continue-on-error: true
- name: Get pull request number
id: get_pullno
run: echo "PULL_NUMBER=$(echo "$GITHUB_REF" | awk -F / '{print $3}')" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/pull/')
- name: Get revision tag
id: get_revtag
run: echo "REVISION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/')
- name: Make artifact name
id: make_artifactname
run: |
if [[ "${{ github.REPOSITORY }}" == "emuflight/EmuFlight" ]] ; then
ARTIFACT_NAME="EmuFlight-${{ env.VERSION }}-${{ github.run_number }}"
else
ARTIFACT_NAME="EmuFlight-${{ env.VERSION }}-${{ github.ACTOR }}-${{ github.run_number }}"
fi
echo "${ARTIFACT_NAME}"
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
# for debugging
- name: Show Variables
id: show_vars
run: |
echo "Actor: ${{ github.ACTOR }}"
echo "Repo: ${{ github.REPOSITORY }}"
echo "Build: ${{ github.run_number }}"
echo "Firmware: ${{ env.VERSION }}"
echo "Commit: ${{ github.sha }}"
echo "Tag: ${{ env.REVISION_TAG}}"
echo "Artifact name: ${{ env.ARTIFACT_NAME }}"
continue-on-error: true
- name: Compile Code
run: |
make ${{ matrix.targets }}
# Upload the Builds to ZIP file with existing SHA in .hex names
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: obj/*.hex
# Upload to Bintray before .hex renames / only for tag
- name: Upload to Bintray
if: startsWith(github.ref, 'refs/tags/')
run: |
curl -fL https://getcli.jfrog.io | sh
export JFROG_CLI_OFFER_CONFIG=false
export CI=true
export JFROG_CLI_LOG_LEVEL=DEBUG
./jfrog bt config --user=${{secrets.BINTRAYUSERNAME}} --key=${{secrets.BINTRAYAPIKEY}} --licenses=GPL-3.0
export repo="emuflight-dev/dev_hex"
export package="${{env.REVISION_TAG}}"
export version="${{github.run_number}}-${{env.VERSION}}-${{env.REVISION_TAG}}"
./jfrog bt package-create --pub-dn=true --vcs-url="https://github.com/emuflight" "${repo}/${package}" || true
./jfrog bt version-create "${repo}/${package}/${version}" || true
./jfrog bt upload --publish=true "obj/*.hex" "${repo}/${package}/${version}" "GitHub_Build_${version}/" || true
continue-on-error: true
# Rename .hex for Releases
- name: Rename Artifacts
if: startsWith(github.ref, 'refs/tags/')
run: |
sudo apt -y install rename
cd obj
rename 's/_Build_.*/.hex/' *.hex
- name: Draft Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: obj/*.hex
draft: true
prerelease: true
tag_name: ${{ github.run_number }} # use the build Number, but we manually change to version so that it creates a version-tag on release
name: DRAFT / EmuFlight ${{ env.VERSION }} / GitHub Build ${{ github.run_number }}
body: |
# EmuFlight ${{ env.VERSION }}
## BuildTag: ${{ env.REVISION_TAG}}
## Commit: ${{ github.sha }}
## Changes in this Release:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}