From f4d07e2c2ccbca77e5744e76769336dba9b60286 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Fri, 28 May 2021 01:25:29 +0300 Subject: [PATCH] CI: move image building to GitHub actions (#335) * Start working on building image in GitHub actions * Trigger GitHub on push to any branch * Fix TRAVIS_TAG * Add compress image step * Disable image build in Travis * Add upload image step * Fix compress image * Fix * Fix * Minor fix * Trigger build on tag * Show images sizes not in human format * Upload only built image * Make prerelease * Upload assets on release not on tags --- .github/workflows/main.yml | 23 ++++++++++- .travis.yml | 82 +++++++++++++++++++------------------- 2 files changed, 63 insertions(+), 42 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 10a05402..00ff488f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,15 +6,36 @@ name: CI on: # Triggers the workflow on push or pull request events but only for the master branch push: - branches: [ master ] + branches: [ '*' ] pull_request: branches: [ master ] + release: + types: [ created ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: + build-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build image + run: | + docker run --privileged --rm -v /dev:/dev -v $(pwd):/builder/repo -e TRAVIS_TAG="${{ github.event.release.tag_name }}" sfalexrog/img-tool:qemu-update + - name: Compress image + run: | + sudo chmod -R 777 images && zip -9 $(echo images/clover_*).zip images/clover_* && ls -l images + - name: Upload image + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + files: images/clover_*.zip + prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # This workflow contains a single job called "build" build: # The type of runner that the job will run on diff --git a/.travis.yml b/.travis.yml index d80d05c4..5004abc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,47 +14,47 @@ git: jobs: fast_finish: true include: - - stage: Build - name: "Raspberry Pi Image Build" - cache: - directories: - - imgcache - before_script: - - if [ ! -z "$DOCKER_USERNAME" ]; then - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin; - fi - - docker pull ${DOCKER} -# Check if there are any cached images, copy them to our "images" directory - - if [ -n "$(ls -A imgcache/*.zip)" ]; then mkdir -p images && cp imgcache/*.zip images; fi - script: - - if [[ -z ${TRAVIS_TAG} && "${TRAVIS_PULL_REQUEST}" != "false" ]]; then - echo "Commit range is ${TRAVIS_COMMIT_RANGE}" && - if [ $(git diff --name-only ${TRAVIS_COMMIT_RANGE} | grep -v ^"docs/" | wc -l) -eq 0 ]; then - echo " === Docs-only change; skipping build ===" && - export SKIP_BUILD=true; - fi; - fi - - if [ -z ${SKIP_BUILD} ]; then - docker run --privileged --rm -v /dev:/dev -v $(pwd):/builder/repo -e TRAVIS_TAG="${TRAVIS_TAG}" ${DOCKER}; - fi - before_cache: - - cp images/*.zip imgcache - after_success: - - sudo chmod -R 777 * - - cd images && zip -9 ${IMAGE_NAME}.zip ${IMAGE_NAME} && stat --printf="Compressed image size:%s\n" ${IMAGE_NAME}.zip - before_deploy: - # Set up git user name and tag this commit - - git config --local user.name "goldarte" - - git config --local user.email "goldartt@gmail.com" - deploy: - provider: releases - token: ${GITHUB_OAUTH_TOKEN} - file: ${IMAGE_NAME}.zip - skip_cleanup: true - on: - tags: true - draft: true - name: ${TRAVIS_TAG} +# - stage: Build +# name: "Raspberry Pi Image Build" +# cache: +# directories: +# - imgcache +# before_script: +# - if [ ! -z "$DOCKER_USERNAME" ]; then +# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin; +# fi +# - docker pull ${DOCKER} +# # Check if there are any cached images, copy them to our "images" directory +# - if [ -n "$(ls -A imgcache/*.zip)" ]; then mkdir -p images && cp imgcache/*.zip images; fi +# script: +# - if [[ -z ${TRAVIS_TAG} && "${TRAVIS_PULL_REQUEST}" != "false" ]]; then +# echo "Commit range is ${TRAVIS_COMMIT_RANGE}" && +# if [ $(git diff --name-only ${TRAVIS_COMMIT_RANGE} | grep -v ^"docs/" | wc -l) -eq 0 ]; then +# echo " === Docs-only change; skipping build ===" && +# export SKIP_BUILD=true; +# fi; +# fi +# - if [ -z ${SKIP_BUILD} ]; then +# docker run --privileged --rm -v /dev:/dev -v $(pwd):/builder/repo -e TRAVIS_TAG="${TRAVIS_TAG}" ${DOCKER}; +# fi +# before_cache: +# - cp images/*.zip imgcache +# after_success: +# - sudo chmod -R 777 * +# - cd images && zip -9 ${IMAGE_NAME}.zip ${IMAGE_NAME} && stat --printf="Compressed image size:%s\n" ${IMAGE_NAME}.zip +# before_deploy: +# # Set up git user name and tag this commit +# - git config --local user.name "goldarte" +# - git config --local user.email "goldartt@gmail.com" +# deploy: +# provider: releases +# token: ${GITHUB_OAUTH_TOKEN} +# file: ${IMAGE_NAME}.zip +# skip_cleanup: true +# on: +# tags: true +# draft: true +# name: ${TRAVIS_TAG} # - stage: Build # name: "Native Kinetic build" # env: