From 7f1af07ae4ea359ad7dfe7672b4b8a1129a156e8 Mon Sep 17 00:00:00 2001 From: Vincent Brison Date: Fri, 24 Apr 2020 11:36:58 +0200 Subject: [PATCH] Implement release flow --- .github/workflows/cd_flow_release.yml | 89 ++++++++++++++++++--------- .github/workflows/cd_release.yml | 22 ------- .github/workflows/ci.yml | 1 + ci_cd.sh | 6 +- 4 files changed, 64 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/cd_release.yml diff --git a/.github/workflows/cd_flow_release.yml b/.github/workflows/cd_flow_release.yml index 1f64a90..ea3bf89 100644 --- a/.github/workflows/cd_flow_release.yml +++ b/.github/workflows/cd_flow_release.yml @@ -4,7 +4,18 @@ on: branches: - 'release/**' jobs: - build_test_and_generate_desc: + job_compute_release_name: + runs-on: ubuntu-18.04 + outputs: + release_name: ${{ steps.step_compute_release_name.outputs.release_name }} + steps: + - id: step_compute_release_name + env: + GIT_REF: ${{ github.ref }} + run: echo "::set-output name=release_name::${GIT_REF#refs/heads/release/}" + + job_build_test_deploy_and_generate_desc: + needs: job_compute_release_name runs-on: ubuntu-18.04 strategy: matrix: @@ -14,10 +25,15 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Build and test image - run: ./ci_cd.sh --build --test --android_api ${{ matrix.android_api }} ${{ matrix.android_ndk }} + - name: Build test deploy image + env: + RELEASE_NAME: ${{ needs.job_compute_release_name.outputs.release_name }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} + FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} + run: ./ci_cd.sh --build --test --deploy --android_api ${{ matrix.android_api }} ${{ matrix.android_ndk }} # For debug purpose, keep while not stable - # run: echo "Building and testing image..." + # run: echo "Building, testing, describing, deloying image..." - name: Generate image description run: ./ci_cd.sh --desc --android_api ${{ matrix.android_api }} ${{ matrix.android_ndk }} @@ -26,53 +42,68 @@ jobs: # touch desc.txt # echo ${{ matrix.android_api }} ${{ matrix.android_ndk }} > desc.txt - - name: Set image name - id: set_image_name + - id: get_image_name + env: + RELEASE_NAME: ${{ needs.job_compute_release_name.outputs.release_name }} run: | image_name=$(./ci_cd.sh --image-name --android_api ${{ matrix.android_api }} ${{ matrix.android_ndk }}) echo "::set-output name=image_name::$image_name" - name: Rename desc file - run: mv desc.txt ${{ steps.set_image_name.outputs.image_name }}.txt + run: mv desc.txt ${{ steps.get_image_name.outputs.image_name }}.txt - name: Upload image description uses: actions/upload-artifact@v2-preview with: - path: ${{ steps.set_image_name.outputs.image_name }}.txt + path: ${{ steps.get_image_name.outputs.image_name }}.txt name: images_description - create_pr: + job_create_release: + needs: [job_compute_release_name, job_build_test_deploy_and_generate_desc] runs-on: ubuntu-18.04 - needs: build_test_and_generate_desc steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Fetch images descriptions - uses: actions/download-artifact@v2-preview + - name: Create release + id: step_create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - name: images_description - path: images_description + tag_name: ${{ needs.job_compute_release_name.outputs.release_name }} + release_name: ${{ needs.job_compute_release_name.outputs.release_name }} + body: ${{ needs.job_compute_release_name.outputs.release_name }} + draft: false + prerelease: false - name: Generate changelog file uses: charmixer/auto-changelog-action@v1 with: token: ${{ secrets.GITHUB_TOKEN}} - - name: Commit and push image descriptions - uses: stefanzweifel/git-auto-commit-action@v4.1.4 + - name: Upload changelog + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - commit_message: Update images description and changelog + upload_url: ${{ steps.step_create_release.outputs.upload_url }} + asset_path: CHANGELOG.md + asset_name: CHANGELOG.md + asset_content_type: text/markdown - - name: Set release name - id: set_release_name - env: - GIT_REF: ${{ github.ref }} - run: echo "::set-output name=release_name::${GIT_REF#refs/heads/releases/}" + - name: Fetch images description + uses: actions/download-artifact@v2-preview + with: + name: images_description + path: images_description + + - name: Zip images description + run: zip -r images_description.zip images_description - - name: Create pull request - uses: vsoch/pull-request-action@1.0.6 + - name: Upload images description + uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PULL_REQUEST_BRANCH: "master" - PULL_REQUEST_TITLE: "Release ${{ steps.set_release_name.outputs.release_name }}" + with: + upload_url: ${{ steps.step_create_release.outputs.upload_url }} + asset_path: images_description.zip + asset_name: images_description.zip + asset_content_type: application/zip diff --git a/.github/workflows/cd_release.yml b/.github/workflows/cd_release.yml deleted file mode 100644 index ba5aa30..0000000 --- a/.github/workflows/cd_release.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Build test deploy release images and create GitHub release -on: - release: - types: [published] -jobs: - build_and_test: - runs-on: ubuntu-18.04 - strategy: - matrix: - android_api: [28, 29] - android_ndk: ["--android_ndk",""] - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Build test & deploy - env: - GIT_REF: ${{ github.ref }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} - FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} - run: ./ci_cd.sh --build --test --deploy --android_api ${{ matrix.android_api }} ${{ matrix.android_ndk }} --large-test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36a896d..b1ef589 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: - develop - master - 'release/**' + - 'release/**' jobs: build_and_test: runs-on: ubuntu-18.04 diff --git a/ci_cd.sh b/ci_cd.sh index 78bf79e..fd0610e 100755 --- a/ci_cd.sh +++ b/ci_cd.sh @@ -77,9 +77,9 @@ branch=${GIT_REF##refs/heads/} if [[ $branch == "develop" ]]; then simple_image_name="$simple_image_name-snapshot" fi -tag=${GIT_REF##refs/tags/} -if [[ $tag =~ $semver_regex ]]; then - simple_image_name="$simple_image_name-$tag" +release_name=$RELEASE_NAME +if [[ $release_name =~ $semver_regex ]]; then + simple_image_name="$simple_image_name-$release_name" fi full_image_name="$org_name/android:$simple_image_name"