From 673082d7fc372ad9acf114fee75e11e400393357 Mon Sep 17 00:00:00 2001 From: saheerb Date: Tue, 15 Jun 2021 19:09:22 +0100 Subject: [PATCH] dsds --- .github/workflows/on-release.yml | 126 ++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 43 deletions(-) diff --git a/.github/workflows/on-release.yml b/.github/workflows/on-release.yml index 7f62693d74c..4151de503c3 100644 --- a/.github/workflows/on-release.yml +++ b/.github/workflows/on-release.yml @@ -1,59 +1,99 @@ -name: build and test image +name: on release + +# The workflow is split into several sub jobs +# 1. prepare-tags: +# This step finds the latest mbed-os version (in terms of product version not date) +# and generates a unique dev version for the image. +# The DEV docker tag takes the format of dev--- +# 2. build-container: +# The dev version of image is built here and pushed to docker hub. +# When multiarch image is built docker buildx doesn't support exporting to docker +# Hence, need to push to a registry (dockerhub). +# 3. test-container: +# This tests the dev docker images +# 4. deploy-container +# At this point, docker image marked as "dev" is ready to tag as "prod" +# Also, deletes the dev tag +# The dev images that didn't succeed is kept in docker hub for troubleshooting purposes. +# Published docker tags are: +# 1. -latest +# 2. - +# 3. latest +# This can be move with another workflow on: - pull_request: - branches: [ master ] - paths: - - docker_images/mbed-os-env/** - - .github/workflows/** + schedule: + - cron: '15 4 * * *' + + push: + # on push master build a new image master-latest for example application + # on push 5.15 build a new image 5.15-latest for example application + # on release 5.15 build a new image 5.15-stable for example application + # on manul + # at night ?? + tags: + - '*' + # paths: + # - docker_images/mbed-os-env/** + # - .github/workflows/** -jobs: + workflow_dispatch: - build-container: +jobs: + prepare-tags: runs-on: ubuntu-latest - - strategy: - matrix: - platform: [linux/amd64, linux/arm64] steps: - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Checkout uses: actions/checkout@v2 - - - # cache documentation: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md - - - name: Build with remote cache - uses: docker/build-push-action@v2 - id: docker_build_dev with: - context: . - platforms: ${{ matrix.platform }} - file: ./mbed-os-env/Dockerfile - load: true - tags: mbed-os-env:a_pr_test - cache-from: type=registry,ref=mbedos/mbed-os-env:latest + fetch-depth: 0 + + - + name: Find the latest tag on the branch + id: mbed_os_version + shell: bash + run: | + value=`git describe --tags --abbrev=0 --match mbed-os-*.[0-9]` + echo "TAG is $value" + echo "::set-output name=tag::$value" + + - + name: Set UUID + id: generate-uuid + uses: filipstefansson/uuid-action@v1 + +# set docker tags we are building, and intending to publish +# dev-tag is temporary for testing purpose. This should be considered as unstable. +# dated-tag is created for versioning purpose +# prod-tag-latest could be used by customers, CI etc for keeping up to date + - + name: Get build information + shell: bash + run: | + mkdir -p build_info + date=$(date +"%Y.%m.%dT%H.%M.%S") + echo dev-${{ steps.extract_branch.outputs.branch }}-${date}-${{ steps.generate-uuid.outputs.uuid }} > build_info/dev_tag + echo ${{ steps.extract_branch.outputs.branch }}-${date} > build_info/prod_tag_dated + echo ${{ steps.extract_branch.outputs.branch }}-latest > build_info/prod_tag_latest + echo ${{ steps.extract_branch.outputs.branch }} > build_info/mbed_os_version + # echo dev-${{ steps.mbed_os_version.outputs.tag }}-${date}-${{ steps.generate-uuid.outputs.uuid }} > build_info/dev_tag + # echo ${{ steps.mbed_os_version.outputs.tag }}-${date} > build_info/prod_tag_dated + # echo ${{ steps.mbed_os_version.outputs.tag }}-latest > build_info/prod_tag_latest + # echo ${{ steps.mbed_os_version.outputs.tag }} > build_info/mbed_os_version + # archiving and unarchiving are github actions ways to pass variables between jobs - - name: test the container - id: test - uses: addnab/docker-run-action@v2 + name: Archive information + uses: actions/upload-artifact@v2 with: - options: -v ${{ github.workspace }}:/work -w=/work - image: mbed-os-env:a_pr_test - shell: bash - run: | - set -e - echo "::set-output name=STATUS::failed" - uname -m - ./mbed-os-env/test.sh + name: build-info + path: build_info + \ No newline at end of file