Skip to content

Commit

Permalink
finalize CI: add correct trigger, create-release step, step names & c…
Browse files Browse the repository at this point in the history
…leanup
  • Loading branch information
umbynos committed Feb 16, 2022
1 parent 83fd21c commit c5a94da
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
name: Release

env:
# The name of the project
PROJECT_NAME: imgtool
DIST_DIR: dist
# AWS_PLUGIN_TARGET: #TODO
ARTIFACT_NAME: dist
# The project's folder on Arduino's download server for uploading builds
AWS_PLUGIN_TARGET: /tools/
# See: https://github.com/actions/setup-python/tree/v2#available-versions-of-python
PYTHON_VERSION: "3.7"

on:
push:
# tags:
# - "[0-9]+.[0-9]+.[0-9]+*" # enable it at the end of developement
tags:
- "[0-9]+.[0-9]+.[0-9]+*"

jobs:
build:
name: build (${{ matrix.package_platform }})
strategy:
fail-fast: false #TODO remove, here only 4 developement
matrix:
os: [windows-latest, ubuntu-18.04, macos-10.15]
python_arch: [x64]
Expand Down Expand Up @@ -64,9 +66,6 @@ jobs:
- name: Upgrade PIP
run: python -m pip install --upgrade pip setuptools wheel

# - name: Display Python version
# run: python --version

- name: Display PIP version
run: pip --version

Expand All @@ -77,24 +76,21 @@ jobs:
- name: Install pyinstaller
run: pip install pyinstaller

# - name: Display Pyinstaller version
# run: pyinstaller --version

- name: Build & Package
if: matrix.os == 'windows-latest'
working-directory: ${{ github.workspace }}/mcuboot/scripts/
run: |
pyinstaller --onefile main.py -n ${{ env.PROJECT_NAME }}.exe
cd ${{ env.DIST_DIR }}
7z a ${{ env.PROJECT_NAME }}_0.0.1_${{ matrix.package_platform }}.zip ${{ env.PROJECT_NAME }}.exe ../../../imgtool-packing/LICENSE.txt #apparently windows does not expand correclty ${{ github.workspace }} for some obscure reason
7z a ${{ env.PROJECT_NAME }}_${GITHUB_REF/refs\/tags\//}_${{ matrix.package_platform }}.zip ${{ env.PROJECT_NAME }}.exe ../../../imgtool-packing/LICENSE.txt #apparently windows does not expand correclty ${{ github.workspace }} for some obscure reason
- name: Build & Package
if: matrix.os != 'windows-latest'
working-directory: ${{ github.workspace }}/mcuboot/scripts/
run: |
pyinstaller --onefile main.py -n ${{ env.PROJECT_NAME }}
cd ${{ env.DIST_DIR }}
${{ matrix.archive_util }} -cz -C ./ ${{ env.PROJECT_NAME }} -C ${{ github.workspace }}/imgtool-packing/ LICENSE.txt -f ${{ env.PROJECT_NAME }}_0.0.1_${{ matrix.package_platform }}.tar.gz
${{ matrix.archive_util }} -cz -C ./ ${{ env.PROJECT_NAME }} -C ${{ github.workspace }}/imgtool-packing/ LICENSE.txt -f ${{ env.PROJECT_NAME }}_${GITHUB_REF/refs\/tags\//}_${{ matrix.package_platform }}.tar.gz
- name: Upload artifacts
uses: actions/upload-artifact@v2
Expand All @@ -104,8 +100,8 @@ jobs:
path: mcuboot/scripts/dist/${{ env.PROJECT_NAME }}_*

build-crosscompile:
name: build (${{ matrix.package_platform }})
strategy:
fail-fast: false #TODO remove, here only 4 developement
matrix:
package_platform: [Linux_32bit, Linux_ARMv6, Linux_ARMv7, Linux_ARM64]
include:
Expand All @@ -114,7 +110,7 @@ jobs:
- package_platform: Linux_ARMv6
docker_image: arm32v5/python:3.7-buster # buster is not available for arm32v6, but should be backward compatible
- package_platform: Linux_ARMv7
docker_image: arm32v7/python:3.7-buster # PyInstaller does not include a pre-compiled bootloader for your platform
docker_image: arm32v7/python:3.7-buster
- package_platform: Linux_ARM64
docker_image: arm64v8/python:3.7-buster

Expand Down Expand Up @@ -148,17 +144,13 @@ jobs:

# Docker containes used to crosscompile:
# https://github.com/docker-library/official-images#architectures-other-than-amd64
- name: ls workspace
working-directory: ${{ github.workspace }}/mcuboot/scripts
run: docker run -v "$(pwd)":/workspace ${{ matrix.docker_image }} ls workspace

- name: Build
working-directory: ${{ github.workspace }}/mcuboot/scripts
run: docker run -v "$(pwd)":/workspace ${{ matrix.docker_image }} ./workspace/imgtool/build.sh

- name: Package
working-directory: ${{ github.workspace }}/mcuboot/scripts/${{ env.DIST_DIR }}
run: sudo tar cz -C ./ ${{ env.PROJECT_NAME }} -C ${{ github.workspace }}/imgtool-packing/ LICENSE.txt -f imgtool_0.0.1_${{ matrix.package_platform }}.tar.gz #dist dir is created in the container with different user/grp
run: sudo tar cz -C ./ ${{ env.PROJECT_NAME }} -C ${{ github.workspace }}/imgtool-packing/ LICENSE.txt -f imgtool_${GITHUB_REF/refs\/tags\//}_${{ matrix.package_platform }}.tar.gz #dist dir is created in the container with different user/grp

- name: Upload artifacts
uses: actions/upload-artifact@v2
Expand All @@ -167,4 +159,32 @@ jobs:
name: ${{ env.ARTIFACT_NAME }}
path: mcuboot/scripts/dist/${{ env.PROJECT_NAME }}_*

# NOTARIZATION & RELEASE
create-release:
runs-on: ubuntu-latest
needs: [build, build-crosscompile]

steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}

- name: Create Github Release and upload artifacts
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
# 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 }}

0 comments on commit c5a94da

Please sign in to comment.