|
| 1 | +# GitHub Action to cross compile a YIO Remote Qt project for the YIO remote-os. |
| 2 | +# Uses the pre-built Buildroot SDK from remote-os in a custom GitHub action. |
| 3 | +# Creates a pre-release if pushed on master branch without a version tag. |
| 4 | +# Creates a release if pushed on master branch with a version tag. |
| 5 | +--- |
| 6 | + name: "Cross Compile & Release" |
| 7 | + |
| 8 | + on: |
| 9 | + push: |
| 10 | + pull_request: |
| 11 | + |
| 12 | + env: |
| 13 | + APP_NAME: libopenweather |
| 14 | + PROJECT_NAME: integration.openweather |
| 15 | + |
| 16 | + jobs: |
| 17 | + build: |
| 18 | + name: ${{ matrix.config.name }} |
| 19 | + runs-on: ubuntu-latest |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + config: |
| 23 | + - { |
| 24 | + name: "RPi0 Release Build", artifact: "remote-release", |
| 25 | + qmake-args: "CONFIG+=release" |
| 26 | + } |
| 27 | + - { |
| 28 | + name: "RPi0 Debug Build", artifact: "remote-debug", |
| 29 | + qmake-args: "CONFIG+=debug CONFIG+=qml_debug" |
| 30 | + } |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: github env vars |
| 34 | + run: | |
| 35 | + echo "$GITHUB_REF" |
| 36 | + echo "$GITHUB_HEAD_REF" |
| 37 | + echo "$GITHUB_BASE_REF" |
| 38 | + |
| 39 | + - name: Checkout ${{ env.PROJECT_NAME}} |
| 40 | + uses: actions/checkout@v2 |
| 41 | + with: |
| 42 | + # History of 500 should be more than enough to calculate commit count since last release tag. |
| 43 | + fetch-depth: 500 |
| 44 | + path: ${{ env.PROJECT_NAME}} |
| 45 | + |
| 46 | + - name: Fetch all tags to determine version |
| 47 | + run: | |
| 48 | + cd ${{ env.PROJECT_NAME}} |
| 49 | + git fetch origin +refs/tags/*:refs/tags/* |
| 50 | + git describe --match "v[0-9]*" --tags HEAD --always |
| 51 | + |
| 52 | + - name: Set build timestamp |
| 53 | + run: echo "::set-env name=TIMESTAMP::$(date +"%Y%m%d_%H%M%S")" |
| 54 | + |
| 55 | + - name: Cross compile |
| 56 | + id: cross-compile |
| 57 | + uses: zehnm/yio-crosscompile-action@master |
| 58 | + with: |
| 59 | + project-name: ${{ env.PROJECT_NAME }} |
| 60 | + output-path: ${GITHUB_WORKSPACE}/binaries/app |
| 61 | + qmake-args: ${{ matrix.config.qmake-args }} |
| 62 | + |
| 63 | + - name: Upload build artefacts |
| 64 | + uses: actions/upload-artifact@v1 |
| 65 | + with: |
| 66 | + path: binaries |
| 67 | + name: ${{ env.APP_NAME }}-${{ matrix.config.artifact }} |
| 68 | + |
| 69 | + release: |
| 70 | + name: Create Release |
| 71 | + if: github.ref == 'refs/heads/master' || contains(github.ref, 'tags/v') |
| 72 | + runs-on: ubuntu-latest |
| 73 | + needs: build |
| 74 | + |
| 75 | + steps: |
| 76 | + - run: mkdir release debug |
| 77 | + - name: Download release artifact |
| 78 | + uses: actions/download-artifact@v1 |
| 79 | + with: |
| 80 | + name: ${{ env.APP_NAME }}-remote-release |
| 81 | + path: ./release |
| 82 | + - name: Download debug artifact |
| 83 | + uses: actions/download-artifact@v1 |
| 84 | + with: |
| 85 | + name: ${{ env.APP_NAME }}-remote-debug |
| 86 | + path: ./debug |
| 87 | + - name: Get artifact version |
| 88 | + run: | |
| 89 | + read -r APP_VERSION < release/version.txt |
| 90 | + echo "::set-env name=APP_VERSION::$APP_VERSION" |
| 91 | + echo "::set-env name=TIMESTAMP::$(date +"%Y%m%d_%H%M%S")" |
| 92 | +
|
| 93 | + - name: Create GitHub release archives |
| 94 | + run: | |
| 95 | + tar cvf ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ env.TIMESTAMP }}-remote-debug.tar -C debug . |
| 96 | + tar cvf ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ env.TIMESTAMP }}-remote-release.tar -C release . |
| 97 | +
|
| 98 | + - name: Create Pre-Release ${{ env.APP_VERSION }} |
| 99 | + uses: "marvinpinto/action-automatic-releases@latest" |
| 100 | + if: "!contains(github.ref, 'tags/v')" |
| 101 | + with: |
| 102 | + repo_token: "${{ secrets.GITHUB_TOKEN }}" |
| 103 | + automatic_release_tag: "latest" |
| 104 | + prerelease: true |
| 105 | + title: "Development Build ${{ env.APP_VERSION }}" |
| 106 | + files: | |
| 107 | + *.tar |
| 108 | +
|
| 109 | + - name: Create Release ${{ env.APP_VERSION }} |
| 110 | + uses: "marvinpinto/action-automatic-releases@latest" |
| 111 | + if: "contains(github.ref, 'tags/v')" |
| 112 | + with: |
| 113 | + repo_token: "${{ secrets.GITHUB_TOKEN }}" |
| 114 | + prerelease: false |
| 115 | + files: | |
| 116 | + *.tar |
0 commit comments