Skip to content

Commit 926c246

Browse files
authored
Add package_index.template generation (#13)
* remove armv7 build, armv6 binaries are also compatible with armv7 * add prerelease check * add `package_index.template` generation and upload && make the bin executable * apply fixes from code review
1 parent 7976506 commit 926c246

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed

.github/workflows/release.yml

+44-3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
working-directory: ${{ env.MCUBOOT_PATH }}/scripts/${{ env.DIST_DIR }}
104104
run: | # we need to create the subdir where to place binaries
105105
mkdir ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }}
106+
chmod +x ./${{ env.PROJECT_NAME }}
106107
mv -v ./${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }}
107108
mv -v ${{ env.IMGTOOL_PACKING_PATH }}/LICENSE.txt ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }}
108109
${{ matrix.archive_util }} -cz ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }} -f ${{ env.PROJECT_NAME }}_${GITHUB_REF/refs\/tags\//}_${{ matrix.package_platform }}.tar.gz
@@ -118,14 +119,12 @@ jobs:
118119
name: build (${{ matrix.package_platform }})
119120
strategy:
120121
matrix:
121-
package_platform: [Linux_32bit, Linux_ARMv6, Linux_ARMv7, Linux_ARM64]
122+
package_platform: [Linux_32bit, Linux_ARMv6, Linux_ARM64]
122123
include:
123124
- package_platform: Linux_32bit
124125
docker_image: i386/python:3.7-buster
125126
- package_platform: Linux_ARMv6
126127
docker_image: arm32v5/python:3.7-buster # buster is not available for arm32v6, but should be backward compatible
127-
- package_platform: Linux_ARMv7
128-
docker_image: arm32v7/python:3.7-buster
129128
- package_platform: Linux_ARM64
130129
docker_image: arm64v8/python:3.7-buster
131130

@@ -175,6 +174,7 @@ jobs:
175174
working-directory: ${{ env.MCUBOOT_PATH }}/scripts/${{ env.DIST_DIR }}
176175
run: | # we need to create the subdir where to place binaries
177176
sudo mkdir ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }}
177+
sudo chmod +x ./${{ env.PROJECT_NAME }}
178178
sudo mv -v ./${{ env.PROJECT_NAME }} ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }}
179179
sudo mv -v ${{ env.IMGTOOL_PACKING_PATH }}/LICENSE.txt ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }}
180180
sudo tar -cz ${{ env.PROJECT_NAME }}_${{ matrix.package_platform }} -f ${{ env.PROJECT_NAME }}_${GITHUB_REF/refs\/tags\//}_${{ matrix.package_platform }}.tar.gz #dist dir is created in the container with different user/grp
@@ -259,17 +259,58 @@ jobs:
259259
needs: [build, build-crosscompile, notarize-macos]
260260

261261
steps:
262+
- name: Checkout repository # we need package_index.template
263+
uses: actions/checkout@v2
264+
262265
- name: Download artifact
263266
uses: actions/download-artifact@v3
264267
with:
265268
name: ${{ env.ARTIFACT_NAME }}
266269
path: ${{ env.DIST_DIR }}
267270

271+
- name: Identify Prerelease
272+
# This is a workaround while waiting for create-release action
273+
# to implement auto pre-release based on tag
274+
id: prerelease
275+
run: |
276+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
277+
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
278+
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
279+
280+
- name: Prepare artifacts for the release and handle package_index
281+
run: |
282+
package_index=`cat package_index.template | sed s/%%VERSION%%/${GITHUB_REF/refs\/tags\//}/`
283+
declare -a target_folders=("Windows_32bit" "Windows_64bit" "Linux_64bit" "macOS_64bit" "Linux_32bit" "Linux_ARMv6" "Linux_ARM64")
284+
cd dist
285+
for folder in "${target_folders[@]}"
286+
do
287+
if [[ $folder = "Windows_32bit" || $folder = "Windows_64bit" ]]; then
288+
ARCHIVE_NAME=${{ env.PROJECT_NAME }}_${GITHUB_REF/refs\/tags\//}_${folder}.zip
289+
else
290+
ARCHIVE_NAME=${{ env.PROJECT_NAME }}_${GITHUB_REF/refs\/tags\//}_${folder}.tar.gz
291+
fi
292+
T_OS=`echo ${folder} | awk '{print toupper($0)}'`
293+
SHASUM=`sha256sum ${ARCHIVE_NAME} | cut -f1 -d" "`
294+
SIZE=`stat --printf="%s" ${ARCHIVE_NAME}`
295+
package_index=`echo $package_index |
296+
sed s/%%FILENAME_${T_OS}%%/${ARCHIVE_NAME}/ |
297+
sed s/%%FILENAME_${T_OS}%%/${ARCHIVE_NAME}/ |
298+
sed s/%%SIZE_${T_OS}%%/${SIZE}/ |
299+
sed s/%%SHA_${T_OS}%%/${SHASUM}/`
300+
done
301+
cd ..
302+
echo ================== CUT ME HERE =====================
303+
echo "${package_index}"
304+
echo "${package_index}" > dist/package_index_draft.json
305+
268306
- name: Create Github Release and upload artifacts
269307
uses: ncipollo/release-action@v1
270308
with:
271309
token: ${{ secrets.GITHUB_TOKEN }}
272310
draft: false
311+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
312+
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
313+
# (all the files we need are in the DIST_DIR root)
273314
artifacts: ${{ env.DIST_DIR }}/*
274315

275316
- name: Upload release files on Arduino downloads servers

package_index.template

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "imgtool",
3+
"version": "%%VERSION%%",
4+
"systems": [
5+
{
6+
"host": "i386-apple-darwin11",
7+
"url": "https://downloads.arduino.cc/tools/%%FILENAME_MACOS_64BIT%%",
8+
"archiveFileName": "%%FILENAME_MACOS_64BIT%%",
9+
"size": "%%SIZE_MACOS_64BIT%%",
10+
"checksum": "SHA-256:%%SHA_MACOS_64BIT%%"
11+
},
12+
{
13+
"host": "arm-linux-gnueabihf",
14+
"url": "https://downloads.arduino.cc/tools/%%FILENAME_LINUX_ARMV6%%",
15+
"archiveFileName": "%%FILENAME_LINUX_ARMV6%%",
16+
"size": "%%SIZE_LINUX_ARMV6%%",
17+
"checksum": "SHA-256:%%SHA_LINUX_ARMV6%%"
18+
},
19+
{
20+
"host": "aarch64-linux-gnu",
21+
"url": "https://downloads.arduino.cc/tools/%%FILENAME_LINUX_ARM64%%",
22+
"archiveFileName": "%%FILENAME_LINUX_ARM64%%",
23+
"size": "%%SIZE_LINUX_ARM64%%",
24+
"checksum": "SHA-256:%%SHA_LINUX_ARM64%%"
25+
},
26+
{
27+
"host": "x86_64-linux-gnu",
28+
"url": "https://downloads.arduino.cc/tools/%%FILENAME_LINUX_64BIT%%",
29+
"archiveFileName": "%%FILENAME_LINUX_64BIT%%",
30+
"size": "%%SIZE_LINUX_64BIT%%",
31+
"checksum": "SHA-256:%%SHA_LINUX_64BIT%%"
32+
},
33+
{
34+
"host": "i686-linux-gnu",
35+
"url": "https://downloads.arduino.cc/tools/%%FILENAME_LINUX_32BIT%%",
36+
"archiveFileName": "%%FILENAME_LINUX_32BIT%%",
37+
"size": "%%SIZE_LINUX_32BIT%%",
38+
"checksum": "SHA-256:%%SHA_LINUX_32BIT%%"
39+
},
40+
{
41+
"host": "i686-mingw32",
42+
"url": "https://downloads.arduino.cc/tools/%%FILENAME_WINDOWS_32BIT%%",
43+
"archiveFileName": "%%FILENAME_WINDOWS_32BIT%%",
44+
"size": "%%SIZE_WINDOWS_32BIT%%",
45+
"checksum": "SHA-256:%%SHA_WINDOWS_32BIT%%"
46+
},
47+
{
48+
"host": "x86_64-mingw32",
49+
"url": "https://downloads.arduino.cc/tools/%%FILENAME_WINDOWS_64BIT%%",
50+
"archiveFileName": "%%FILENAME_WINDOWS_64BIT%%",
51+
"size": "%%SIZE_WINDOWS_64BIT%%",
52+
"checksum": "SHA-256:%%SHA_WINDOWS_64BIT%%"
53+
}
54+
]
55+
}

0 commit comments

Comments
 (0)