Skip to content

Commit

Permalink
Merge pull request #31 from Zondax/ci-version
Browse files Browse the repository at this point in the history
improve CI
  • Loading branch information
ftheirs committed Jul 1, 2022
2 parents 2f4d80a + 61cc61a commit a804630
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
47 changes: 41 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: "Test/Build"
on:
workflow_dispatch:
push:
pull_request:
branches: [ main ]
name: "Main workflow"
on: push

jobs:
configure:
Expand All @@ -27,3 +23,42 @@ jobs:
brew install conan
conan config install https://github.com/conan-io/conanclientcert.git
- run: cmake -DCMAKE_BUILD_TYPE=Debug . && make

check_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
exists: ${{ steps.get-version.outputs.exists }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- id: get-version
name: Get zxlib version
run: echo ::set-output name=version::$(./scripts/get_version.sh)
- id: tag-exists
name: Check if version exists
run: |
if git rev-parse ${{ steps.get-version.outputs.version }} >/dev/null 2>&1; then
echo ::set-output name=exists::true
else
echo ::set-output name=exists::false
fi
- name: Fail if tag exists
if: ${{ steps.tag-exists.outputs.exists == 'true' }}
run: exit 1

tag:
runs-on: ubuntu-latest
needs:
- build
- check_version
if: ${{ needs.check_version.outputs.exists != 'true' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.check_version.outputs.version }}
2 changes: 1 addition & 1 deletion include/zxversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

#define ZXLIB_MAJOR 14
#define ZXLIB_MINOR 0
#define ZXLIB_PATCH 3
#define ZXLIB_PATCH 4
5 changes: 5 additions & 0 deletions scripts/get_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

zxpath="$(dirname "$0")/../include/zxversion.h"
version_numbers=$(sed '/[0-9]/!d; /*/d; s/[A-Za-z#_ ]//g' "$zxpath" | tr '\n' '.')
echo "v${version_numbers%?}" # %? stands for removing the last character of the file as `tr` adds an extra `.`

0 comments on commit a804630

Please sign in to comment.