forked from avrdudes/avrdude
-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (203 loc) · 9.96 KB
/
release.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: release
env:
# The name of the project
PROJECT_NAME: avrdude
DIST_DIR: dist
ARTIFACT_NAME: dist
# The project's folder on Arduino's download server for uploading builds
AWS_PLUGIN_TARGET: /tools/
AVRDUDE_PACKING_PATH: ${{ github.workspace }}/avrdude-packing
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
jobs:
build:
name: build (${{ matrix.config.os }}, ${{ matrix.config.arch }})
runs-on:
ubuntu-latest
strategy:
fail-fast: false #here only for debug
matrix:
config:
- os: Linux
arch: 64bit
cross_compile: x86_64-ubuntu16.04-linux-gnu
- os: Linux
arch: 32bit
cross_compile: i686-ubuntu16.04-linux-gnu
- os: Linux
arch: ARMv6
cross_compile: arm-linux-gnueabihf
- os: Linux
arch: ARM64
cross_compile: aarch64-linux-gnu
- os: macOS
arch: 64bit
cross_compile: x86_64-apple-darwin13
cross_compiler: o64-clang
ar: /opt/osxcross/target/bin/x86_64-apple-darwin13-ar # we have to manually specify the full path otherwise it's not found for some reason
ld: /opt/osxcross/target/bin/x86_64-apple-darwin13-ld
- os: Windows
arch: 32bit
cross_compile: i686-w64-mingw32
extension: .exe
container:
image: ghcr.io/arduino/crossbuild:0.2.0
credentials:
username: ${{ github.actor }}
password: ${{ secrets.AVRDUDE_CI_PAT }}
steps:
# ideally this repo should contain only the patches that could not be upstreamed and the release CI nothing else
- name: Checkout avrdude repository
uses: actions/checkout@v3
with:
path: ${{ env.AVRDUDE_PACKING_PATH }} #maybe rename the repo with this name
- name: replace system ranlib with darwin one
# for some reason is not possible to override ranlib with env vars, so this is ugly but it's the only way I found
if: matrix.config.os == 'macOS'
run: |
mv /usr/bin/ranlib /usr/bin/ranlib.bk
ln -s /opt/osxcross/target/bin/${{ matrix.config.cross_compile }}-ranlib /usr/bin/ranlib
- name: Build Avrdude
working-directory: ${{ env.AVRDUDE_PACKING_PATH }}
run: |
if [ "${{ matrix.config.os }}" = "macOS" ]; then
# For darwin we disable the static flags (not supported by clang) and we make some adjustments
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compiler }}++ -DCMAKE_AR=${{ matrix.config.ar }} -DCMAKE_LINKER=${{ matrix.config.ld}} -DCMAKE_EXE_LINKER_FLAGS="-L/opt/lib/${{ matrix.config.cross_compile }}/lib/" -DCMAKE_C_FLAGS="-I/opt/lib/${{ matrix.config.cross_compile }}/include -pthread -framework Foundation -framework IOKit -framework Cocoa -DHAVE_USB_H" -DCMAKE_PREFIX_PATH=/opt/lib/${{ matrix.config.cross_compile }}/ -DHAVE_LIBFTDI="NO" -B build/
else
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compile }}-gcc -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compile }}-g++ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-I/opt/lib/${{ matrix.config.cross_compile }}/include/libusb-1.0/ -I/opt/lib/${{ matrix.config.cross_compile }}/include -pthread" -DCMAKE_PREFIX_PATH=/opt/lib/${{ matrix.config.cross_compile }}/ -DHAVE_LIBFTDI="NO" -B build/
fi
cmake --build build/ -v
- name: Package
working-directory: ${{ env.AVRDUDE_PACKING_PATH }}
run: | # we need to create the subdir where to place binaries
mkdir -p ${{ env.PROJECT_NAME }}_${{ matrix.config.os }}_${{ matrix.config.arch }}/bin ${{ env.PROJECT_NAME }}_${{ matrix.config.os }}_${{ matrix.config.arch }}/etc
chmod +x build/src/${{ env.PROJECT_NAME }}${{ matrix.config.extension }}
mv -v build/src/${{ env.PROJECT_NAME }}${{ matrix.config.extension }} ${{ env.PROJECT_NAME }}_${{ matrix.config.os }}_${{ matrix.config.arch }}/bin
mv -v build/src/${{ env.PROJECT_NAME }}.conf ${{ env.PROJECT_NAME }}_${{ matrix.config.os }}_${{ matrix.config.arch }}/etc
mv -v COPYING ${{ env.PROJECT_NAME }}_${{ matrix.config.os }}_${{ matrix.config.arch }}/LICENSE.txt
tar -czv ${{ env.PROJECT_NAME }}_${{ matrix.config.os }}_${{ matrix.config.arch }} -f ${{ env.PROJECT_NAME }}_${GITHUB_REF##*/}_${{ matrix.config.os }}_${{ matrix.config.arch }}.tar.gz
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.AVRDUDE_PACKING_PATH }}/${{ env.PROJECT_NAME }}_*
notarize-macos:
runs-on: macos-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}
- name: Import Code-Signing Certificates
env:
KEYCHAIN: "sign.keychain"
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
run: |
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > "${{ env.INSTALLER_CERT_MAC_PATH }}"
security create-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
security default-keychain -s "${{ env.KEYCHAIN }}"
security unlock-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
security import \
"${{ env.INSTALLER_CERT_MAC_PATH }}" \
-k "${{ env.KEYCHAIN }}" \
-f pkcs12 \
-A \
-T "/usr/bin/codesign" \
-P "${{ secrets.INSTALLER_CERT_MAC_PASSWORD }}"
security set-key-partition-list \
-S apple-tool:,apple: \
-s \
-k "${{ env.KEYCHAIN_PASSWORD }}" \
"${{ env.KEYCHAIN }}"
- name: Install gon for code signing and app notarization
run: |
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
unzip gon_macos.zip -d /usr/local/bin
- name: Sign and notarize binary
env:
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
run: |
gon gon.config.hcl
- name: Re-package binary
# This step performs the following:
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
run: |
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
# so we need to add execution permission back until the action is made to do this.
chmod +x ${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_macOS_64bit/bin/${{ env.PROJECT_NAME }}
TAG="${GITHUB_REF/refs\/tags\//}"
tar -czvf "${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_${TAG}_macOS_64bit.tar.gz" \
-C ${{ env.DIST_DIR }}/ ${{ env.PROJECT_NAME }}_macOS_64bit/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}
create-release:
runs-on:
ubuntu-latest
needs: [build, notarize-macos]
steps:
- name: Checkout avrdude repository # we need package_index.template
uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}
- name: Identify Prerelease
# This is a workaround while waiting for create-release action
# to implement auto pre-release based on tag
id: prerelease
run: |
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
- name: Prepare artifacts for the release and handle package_index
run: |
package_index=`cat package_index.template | sed s/%%VERSION%%/${GITHUB_REF##*/}/`
declare -a target_folders=("Windows_32bit" "Linux_64bit" "macOS_64bit" "Linux_32bit" "Linux_ARMv6" "Linux_ARM64")
cd dist
for folder in "${target_folders[@]}"
do
ARCHIVE_NAME=${{ env.PROJECT_NAME }}_${GITHUB_REF/refs\/tags\//}_${folder}.tar.gz
T_OS=`echo ${folder} | awk '{print toupper($0)}'`
SHASUM=`sha256sum ${ARCHIVE_NAME} | cut -f1 -d" "`
SIZE=`stat --printf="%s" ${ARCHIVE_NAME}`
package_index=`echo $package_index |
sed s/%%FILENAME_${T_OS}%%/${ARCHIVE_NAME}/ |
sed s/%%FILENAME_${T_OS}%%/${ARCHIVE_NAME}/ |
sed s/%%SIZE_${T_OS}%%/${SIZE}/ |
sed s/%%SHA_${T_OS}%%/${SHASUM}/`
done
cd ..
echo ================== CUT ME HERE =====================
echo ${package_index}
echo ${package_index} > package_index_draft.json
- name: Create Github Release and upload artifacts
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
# (all the files we need are in the DIST_DIR root)
artifacts: ${{ env.DIST_DIR }}/*
- name: Upload release files on Arduino downloads servers
uses: docker://plugins/s3
env:
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}