Skip to content

Commit

Permalink
Implement release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Brison committed Apr 24, 2020
1 parent 0a21c9c commit 7f1af07
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 54 deletions.
89 changes: 60 additions & 29 deletions .github/workflows/cd_flow_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand All @@ -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
22 changes: 0 additions & 22 deletions .github/workflows/cd_release.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- develop
- master
- 'release/**'
- 'release/**'
jobs:
build_and_test:
runs-on: ubuntu-18.04
Expand Down
6 changes: 3 additions & 3 deletions ci_cd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7f1af07

Please sign in to comment.