Skip to content

Commit

Permalink
Add release action
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbosch committed Apr 8, 2024
1 parent c958fd7 commit 1637c0e
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 30 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/create_draft_release.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 23 additions & 10 deletions .github/workflows/kuksa_databroker-cli_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -200,9 +212,10 @@ 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
# TODO : use real repo
uses: erikbosch/kuksa-actions/check-dash@main
with:
dashinput: ${{github.workspace}}/dash-databroker-deps
dashinput: ${{github.workspace}}/dash-databroker-cli
51 changes: 33 additions & 18 deletions .github/workflows/kuksa_databroker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -90,6 +91,7 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
needs: [bom]
env:
CARGO_TERM_COLOR: always
strategy:
Expand All @@ -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: |
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -294,21 +308,22 @@ 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
# TODO : use real repo
uses: erikbosch/kuksa-actions/check-dash@main
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
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 1637c0e

Please sign in to comment.