Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
ci: Add a cript to generate the project version
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Polyakov <[email protected]>
  • Loading branch information
maxpoliak committed Oct 29, 2021
1 parent 2c9320a commit 327e927
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/action-build-all-i386.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ jobs:
run: sudo localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
- name: 'Step 4: Make preparations'
run: ./preparations.sh
- name: 'Step 5: Build cross-tools'
- name: 'Step 5: Generate the project version'
run: |
pversion=$(bash ./ci/ci-generate-version.sh --branch ${{ github.head_ref }})
echo ${pversion}
- name: 'Step 6: Build cross-tools'
run: ./build.sh cross
- name: 'Step 6: Build RTEMS'
- name: 'Step 7: Build RTEMS'
run: ./build.sh rtems
- name: 'Step 7: Build application'
- name: 'Step 8: Build application'
run: |
./build.sh
version=$(basename *.tar.gz .tar.gz)
echo $version
echo "::set-env name=VERSION::$version"
- name: 'Step 8: Upload artifact with the result exe image'
- name: 'Step 9: Upload artifact with the result exe image'
uses: actions/upload-artifact@v2
with:
name: '${{ env.VERSION }}-exe-artifact'
Expand Down
73 changes: 73 additions & 0 deletions ci/ci-generate-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash -eu

RTEMS_ARCH="i386"
RTEMS_BSP="pc386"

CI_DIR="$(dirname $(realpath ${BASH_SOURCE[0]}))"
ROOT_DIR="${CI_DIR}/.."
RTEMS_DIR="${ROOT_DIR}/rtems_rtos"
FLAG_RTEMS_VERSION=0

function print_help() {
echo "Use $0 COMMANDS [OPTIONS...]"
echo "Generates a project version label according to the following rules:"
echo " <architecture>-<bsp>-<rtems git tag>-<current branch>-<git tag>"
echo " "
echo " rtems Generate RTEMS version lable"
echo " <architecture>-<bsp>-<current branch>-<rtems git tag>"
echo " --arch <architecture> Set CPU architecture (${RTEMS_ARCH} by default)"
echo " --bsp <bsp> Set board support package (${RTEMS_BSP} by default)"
echo " --branch <git-branch> Set current git branch name for workflow action"
echo " --help Print help"
}

function get_version_lable_rtems_os() {
base=$(git -C ${RTEMS_DIR}/rtems describe --tags --dirty)
branch=$(git -C ${RTEMS_DIR}/rtems symbolic-ref -q --short HEAD)
echo ${RTEMS_ARCH}"-"${RTEMS_BSP}"-"$1"-"$base
}

function get_version_lable_proj() {
version_rtems=$(git -C ${RTEMS_DIR}/rtems describe --always --abbrev=6)
version_base=$(git -C ${ROOT_DIR} describe --tags --dirty --abbrev=4)
echo ${RTEMS_ARCH}"-"${RTEMS_BSP}"-"$version_rtems"-"$1"-"$version_base
}

branch=$(git -C ${ROOT_DIR} symbolic-ref -q --short HEAD)

while [ "${1:-}" != "" ]; do
case "$1" in
"rtems")
FLAG_RTEMS_VERSION=1
branch=$(git -C ${RTEMS_DIR}/rtems symbolic-ref -q --short HEAD)
shift 1
;;
"--arch")
RTEMS_ARCH=$2
shift 2
;;
"--bsp")
RTEMS_BSP=$2
shift 2
;;
"--branch")
branch=$2
shift 2
;;
"-h" | "--help")
print_help
exit 0
;;
*)
echo "invalid command or option ($1)"
print_help
exit 1
;;
esac
done

if [[ ${FLAG_RTEMS_VERSION} -eq 1 ]] ; then
get_version_lable_rtems_os ${branch}
else
get_version_lable_proj ${branch}
fi;

0 comments on commit 327e927

Please sign in to comment.