From 1ef2eb339c901fdbc248a7706c522ab717369b84 Mon Sep 17 00:00:00 2001 From: Erik Jaegervall Date: Thu, 4 Apr 2024 14:05:28 +0200 Subject: [PATCH] Add release action --- .github/workflows/create_draft_release.yml | 93 +++++++++++++++++++ .../workflows/kuksa_databroker-cli_build.yml | 32 +++++-- .github/workflows/kuksa_databroker_build.yml | 50 ++++++---- Dockerfile | 3 + prepare_release.sh | 5 +- 5 files changed, 153 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/create_draft_release.yml diff --git a/.github/workflows/create_draft_release.yml b/.github/workflows/create_draft_release.yml new file mode 100644 index 00000000..38732c1f --- /dev/null +++ b/.github/workflows/create_draft_release.yml @@ -0,0 +1,93 @@ +# /******************************************************************************** +# * Copyright (c) 2024 Contributors to the Eclipse Foundation +# * +# * See the NOTICE file(s) distributed with this work for additional +# * information regarding copyright ownership. +# * +# * This program and the accompanying materials are made available under the +# * terms of the Apache License 2.0 which is available at +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * SPDX-License-Identifier: Apache-2.0 +# ********************************************************************************/ + +name: Create Draft Release + +on: + workflow_dispatch: # input version manually. Overrides push tag + inputs: + tag: + description: "Release version, eg:latest, 0.2.1" + required: true + default: "0.0.0" + + # As of today trigger only manually + #push: + # tags: + # - "*.*.*" + +# Needed if GITHUB_TOKEN by default do not have right to create release +permissions: + contents: write + packages: write + +jobs: + get_version: + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + version: ${{ steps.eval_version.outputs.version }} + steps: + - name: Get tag or user release version + id: eval_version + run: | + GIT_VER="${GITHUB_REF/refs\/tags\//}" + echo "### Detected tag: $GIT_VER" + if [ -n "${{ github.event.inputs.tag }}" ]; then + GIT_VER="${{ github.event.inputs.tag }}" + echo "Forced release version: $GIT_VER" + echo "version=${GIT_VER}" >> $GITHUB_OUTPUT + else + echo "version=${GIT_VER}" >> $GITHUB_OUTPUT + fi + + call_kuksa_databroker_build: + uses: ./.github/workflows/kuksa_databroker_build.yml + call_kuksa_databroker-cli_build: + uses: ./.github/workflows/kuksa_databroker-cli_build.yml + + create_release: + runs-on: ubuntu-latest + needs: + [ + get_version, + call_kuksa_databroker_build, + call_kuksa_databroker-cli_build, + ] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: build-artifacts + # Only packed binaries shall start with "databroker" + # As of now do not upload separate dash and third party reports + pattern: databroker* + merge-multiple: true + - name: Display structure of downloaded files + run: ls -R build-artifacts + + - name: Create release + id: create_release + uses: softprops/action-gh-release@v2 + # if: startsWith(github.ref, 'refs/tags/' + with: + draft: true + tag_name: ${{ needs.get_version.outputs.version }} + fail_on_unmatched_files: true + files: | + build-artifacts/* + LICENSE + NOTICE.md diff --git a/.github/workflows/kuksa_databroker-cli_build.yml b/.github/workflows/kuksa_databroker-cli_build.yml index 76531199..4483aa19 100644 --- a/.github/workflows/kuksa_databroker-cli_build.yml +++ b/.github/workflows/kuksa_databroker-cli_build.yml @@ -27,7 +27,7 @@ on: workflow_dispatch: concurrency: - group: ${{ github.ref }}-${{ github.workflow }} + group: ${{ github.ref }}-${{ github.workflow }}-dbcli cancel-in-progress: true # Needed as default_workflow_permissions is "read" @@ -160,24 +160,36 @@ jobs: uses: eclipse-kuksa/kuksa-actions/post-container-location@2 with: image: ttl.sh/eclipse-kuksa/kuksa-databroker-cli-${{github.sha}} + - name: Pack binaries with thirdparty + env: + AMD64_DIR: ${{ github.workspace }}/dist/amd64 + ARM64_DIR: ${{ github.workspace }}/dist/arm64 + RISCV64_DIR: ${{ github.workspace }}/dist/riscv64 + run: | + cd "$AMD64_DIR" + tar czf databroker-cli-amd64.tar.gz * + cd "$ARM64_DIR" + tar czf databroker-cli-arm64.tar.gz * + cd "$RISCV64_DIR" + tar czf databroker-cli-riscv64.tar.gz * - name: "Archiving AMD64 artifacts" uses: actions/upload-artifact@v4 with: - name: databroker-cli-amd64 - path: ${{github.workspace}}/dist/amd64 + name: databroker-cli-amd64.tar.gz + path: ${{github.workspace}}/dist/amd64/databroker-cli-amd64.tar.gz - name: "Archiving ARM64 artifacts" uses: actions/upload-artifact@v4 with: - name: databroker-cli-arm64 - path: ${{github.workspace}}/dist/arm64 + name: databroker-cli-arm64.tar.gz + path: ${{github.workspace}}/dist/arm64/databroker-cli-arm64.tar.gz - name: "Archiving RISCV64 artifacts" uses: actions/upload-artifact@v4 with: - name: databroker-cli-riscv64 - path: ${{github.workspace}}/dist/riscv64 + name: databroker-cli-riscv64.tar.gz + path: ${{github.workspace}}/dist/riscv64/databroker-cli-riscv64.tar.gz bom: @@ -200,9 +212,9 @@ jobs: working-directory: ${{github.workspace}}/createbom run: | which cargo-license || cargo install cargo-license - python3 createbom.py --dash ${{github.workspace}}/dash-databroker-deps ../databroker + python3 createbom.py --dash ${{github.workspace}}/dash-databroker-cli ../databroker - name: Dash license check - uses: eclipse-kuksa/kuksa-actions/check-dash@2 + uses: eclipse-kuksa/kuksa-actions/check-dash@3 with: - dashinput: ${{github.workspace}}/dash-databroker-deps + dashinput: ${{github.workspace}}/dash-databroker-cli diff --git a/.github/workflows/kuksa_databroker_build.yml b/.github/workflows/kuksa_databroker_build.yml index 7eca6b5f..5b5eb9a5 100644 --- a/.github/workflows/kuksa_databroker_build.yml +++ b/.github/workflows/kuksa_databroker_build.yml @@ -20,8 +20,9 @@ on: workflow_call: workflow_dispatch: +# db/dbcli suffix to group to avoid cancellation when running from release workflow concurrency: - group: ${{ github.ref }}-${{ github.workflow }} + group: ${{ github.ref }}-${{ github.workflow }}-db cancel-in-progress: true # Needed as default_workflow_permissions is "read" @@ -90,6 +91,7 @@ jobs: build: name: Build runs-on: ubuntu-latest + needs: [bom] env: CARGO_TERM_COLOR: always strategy: @@ -103,6 +105,14 @@ jobs: target: riscv64gc-unknown-linux-gnu steps: - uses: actions/checkout@v4 + - name: Retrieve artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + pattern: Third* + merge-multiple: true + - name: Display structure of downloaded files + run: ls -R - uses: actions/cache@v4 with: path: | @@ -120,19 +130,21 @@ jobs: working-directory: ${{github.workspace}}/ run: | cross build --target ${{ matrix.platform.target }} --bin databroker --release - mkdir -p "dist/${{ matrix.platform.name }}" - cp "target/${{ matrix.platform.target }}/release/databroker" "dist/${{ matrix.platform.name }}" + mkdir -p "dist" + cp "target/${{ matrix.platform.target }}/release/databroker" "dist" - name: Package dist files shell: bash working-directory: ${{github.workspace}} run: | - tar -cf databroker-${{ matrix.platform.name }}.tar.gz dist + cd dist + tar xf ../artifacts/thirdparty.tar.gz + tar -czf databroker-${{ matrix.platform.name }}.tar.gz * - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: databroker-${{ matrix.platform.name }}.tar.gz - path: databroker-${{ matrix.platform.name }}.tar.gz + path: dist/databroker-${{ matrix.platform.name }}.tar.gz if-no-files-found: error check_ghcr_push: @@ -160,16 +172,18 @@ jobs: ARM64_DIR: ${{ github.workspace }}/target/aarch64-unknown-linux-musl/release RISCV64_DIR: ${{ github.workspace }}/target/riscv64gc-unknown-linux-gnu/release run: | - tar xf artifacts/databroker-amd64.tar.gz + cd artifacts + tar xf databroker-amd64.tar.gz mkdir -p "$AMD64_DIR" - mv dist/amd64/databroker "$AMD64_DIR" - tar xf artifacts/databroker-arm64.tar.gz + mv databroker "$AMD64_DIR" + tar xf databroker-arm64.tar.gz mkdir -p "$ARM64_DIR" - mv dist/arm64/databroker "$ARM64_DIR" - tar xf artifacts/databroker-riscv64.tar.gz + mv databroker "$ARM64_DIR" + tar xf databroker-riscv64.tar.gz mkdir -p "$RISCV64_DIR" - mv dist/riscv64/databroker "$RISCV64_DIR" - tar xf artifacts/thirdparty.tar.gz + mv databroker "$RISCV64_DIR" + tar xf thirdparty.tar.gz + mv thirdparty ../databroker/ - name: Set container metadata id: meta uses: docker/metadata-action@v5 @@ -294,21 +308,21 @@ jobs: - name: License check and Dash output generation working-directory: ${{github.workspace}}/createbom run: | - python3 createbom.py --dash ${{github.workspace}}/dash-databroker-deps ../databroker + python3 createbom.py --dash ${{github.workspace}}/dash-databroker ../databroker - name: Dash license check - uses: eclipse-kuksa/kuksa-actions/check-dash@2 + uses: eclipse-kuksa/kuksa-actions/check-dash@3 with: - dashinput: ${{github.workspace}}/dash-databroker-deps + dashinput: ${{github.workspace}}/dash-databroker - name: Generate Bill of Materials working-directory: ${{github.workspace}}/createbom run: | rm -r ../databroker/thirdparty python3 createbom.py ../databroker - cd .. - tar cf thirdparty.tar.gz databroker/thirdparty + cd ../databroker + tar czf thirdparty.tar.gz thirdparty - name: Upload Bill of Materials uses: actions/upload-artifact@v4 with: name: Third party licenses - path: thirdparty.tar.gz + path: databroker/thirdparty.tar.gz if-no-files-found: error diff --git a/Dockerfile b/Dockerfile index 679ab113..bc405613 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,6 +44,9 @@ COPY ./target/riscv64gc-unknown-linux-gnu/release/databroker /app/databroker FROM target-$TARGETARCH as target ARG TARGETARCH + +# Before running this file thirdparty files must have been created +# by build-all-targets.sh or corresponding command in buildaction COPY ./databroker/thirdparty/ /app/thirdparty COPY ./data/vss-core/vss_release_3.1.1.json vss_release_3.1.1.json diff --git a/prepare_release.sh b/prepare_release.sh index 3615edb6..ea0fbb58 100755 --- a/prepare_release.sh +++ b/prepare_release.sh @@ -32,9 +32,10 @@ DATA_BROKER_ROOT="$SCRIPT_DIR" # Update Cargo.toml versions. sed -i -E "s/^version = \"${VERSION_REGEX}\"$/version = \"${VERSION}\"/" \ "$DATA_BROKER_ROOT/databroker/Cargo.toml" \ - "$DATA_BROKER_ROOT/databroker-api/Cargo.toml" \ "$DATA_BROKER_ROOT/databroker-cli/Cargo.toml" \ - "$DATA_BROKER_ROOT/databroker-examples/Cargo.toml" + "$DATA_BROKER_ROOT/databroker-proto/Cargo.toml" \ + "$DATA_BROKER_ROOT/lib/sdv/Cargo.toml" \ + "$DATA_BROKER_ROOT/lib/common/Cargo.toml" # Create release commit and tag it #git commit -a -m "Release ${VERSION}"