From b9e366de1d8d21fa479a42497d45a4efa4de2268 Mon Sep 17 00:00:00 2001 From: Michael Voigt <91879843+mvoigt-sag@users.noreply.github.com> Date: Fri, 26 Apr 2024 06:38:52 +0200 Subject: [PATCH] [CTM-1130] implement workflow to create a GH release (#11) Co-authored-by: Michael Voigt --- .github/workflows/build.yml | 15 ++++++++-- .github/workflows/release.yml | 52 +++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 654b1d1..d7fefcc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,7 @@ name: Build on: workflow_dispatch: + workflow_call: pull_request: jobs: @@ -23,6 +24,16 @@ jobs: echo "Found version: $VERSION" echo "marketing_build_version=$VERSION" >> $GITHUB_OUTPUT + - name: Write version to file + run: | + echo "${{ steps.decide_build_number.outputs.marketing_build_version }}" > version.txt + + - name: Upload version + uses: actions/upload-artifact@v3 + with: + name: version + path: version.txt + - name: Invoke Gradle for aar run: | chmod +x gradlew @@ -33,7 +44,7 @@ jobs: env: MARKETING_VERSION: ${{ steps.decide_build_number.outputs.marketing_build_version }} with: - name: 'cumulocity-clients-kotlin-${{ env.MARKETING_VERSION }}' + name: 'cumulocity-clients-kotlin-aar' path: 'build/outputs/aar/*.aar' - name: Invoke Gradle for jar @@ -46,5 +57,5 @@ jobs: env: MARKETING_VERSION: ${{ steps.decide_build_number.outputs.marketing_build_version }} with: - name: 'cumulocity-clients-kotlin-${{ env.MARKETING_VERSION }}' + name: 'cumulocity-clients-kotlin-jar' path: 'build/libs/*.jar' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dd4f129..cc113b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,18 +8,66 @@ jobs: uses: ./.github/workflows/build.yml release: + needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - name: Download version + uses: actions/download-artifact@v3 + with: + name: version + + - name: Set version as env variable + id: set_build_number + run: | + echo "marketing_build_version=$(cat version.txt)" >> $GITHUB_ENV + - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token with: - tag_name: TODOextractVersion - release_name: Release ${{ github.ref_name }} + tag_name: v${{ env.marketing_build_version }} + release_name: Release ${{ env.marketing_build_version }} body: | New release of the generated Kotlin client. draft: false prerelease: false + + - name: Download aar artifact + uses: actions/download-artifact@v3 + with: + name: cumulocity-clients-kotlin-aar + path: artifacts + + - name: Download jar artifact + uses: actions/download-artifact@v3 + with: + name: cumulocity-clients-kotlin-jar + path: artifacts + + - name: show downloaded content + run: | + ls -lsa artifacts/ + + - name: Upload aar to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: "cumulocity-clients-kotlin-release.aar" + asset_path: artifacts/cumulocity-clients-kotlin-release-${{ env.marketing_build_version }}.aar + asset_content_type: application/zip + + - name: Upload jar to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: "cumulocity-clients-kotlin-${{ env.marketing_build_version }}.jar" + asset_path: artifacts/cumulocity-clients-kotlin-${{ env.marketing_build_version }}.jar + asset_content_type: application/zip