|
| 1 | +name: Release automation |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + commit_id: |
| 7 | + description: 'Commit ID to tag and create a release for' |
| 8 | + required: true |
| 9 | + version_number: |
| 10 | + description: 'Release Version Number (Eg, v1.0.0)' |
| 11 | + required: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + tag-commit: |
| 15 | + name: Tag commit |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v2 |
| 20 | + with: |
| 21 | + ref: ${{ github.event.inputs.commit_id }} |
| 22 | + - name: Configure git identity |
| 23 | + run: | |
| 24 | + git config --global user.name "Release Workflow" |
| 25 | + - name: Tag Commit and Push to remote |
| 26 | + run: | |
| 27 | + git tag ${{ github.event.inputs.version_number }} -a -m "FreeRTOS-Cellular-Interface Library ${{ github.event.inputs.version_number }}" |
| 28 | + git push origin --tags |
| 29 | + - name: Verify tag on remote |
| 30 | + run: | |
| 31 | + git tag -d ${{ github.event.inputs.version_number }} |
| 32 | + git remote update |
| 33 | + git checkout tags/${{ github.event.inputs.version_number }} |
| 34 | + git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }} |
| 35 | + create-zip: |
| 36 | + needs: tag-commit |
| 37 | + name: Create ZIP and verify package for release asset. |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Install ZIP tools |
| 41 | + run: sudo apt-get install zip unzip |
| 42 | + - name: Checkout code |
| 43 | + uses: actions/checkout@v2 |
| 44 | + with: |
| 45 | + ref: ${{ github.event.inputs.commit_id }} |
| 46 | + path: FreeRTOS-Cellular-Interface |
| 47 | + submodules: recursive |
| 48 | + - name: Checkout disabled submodules |
| 49 | + run: | |
| 50 | + cd FreeRTOS-Cellular-Interface |
| 51 | + git submodule update --init --checkout --recursive |
| 52 | + - name: Create ZIP |
| 53 | + run: | |
| 54 | + zip -r FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip FreeRTOS-Cellular-Interface -x "*.git*" |
| 55 | + ls ./ |
| 56 | + - name: Validate created ZIP |
| 57 | + run: | |
| 58 | + mkdir zip-check |
| 59 | + mv FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip zip-check |
| 60 | + cd zip-check |
| 61 | + unzip FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip -d FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }} |
| 62 | + ls FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }} |
| 63 | + diff -r -x "*.git*" FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}/FreeRTOS-Cellular-Interface/ ../FreeRTOS-Cellular-Interface/ |
| 64 | + cd ../ |
| 65 | + - name: Build |
| 66 | + run: | |
| 67 | + cd zip-check/FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}/FreeRTOS-Cellular-Interface |
| 68 | + sudo apt-get install -y lcov |
| 69 | + cmake -S test -B build/ \ |
| 70 | + -G "Unix Makefiles" \ |
| 71 | + -DCMAKE_BUILD_TYPE=Debug \ |
| 72 | + -DBUILD_CLONE_SUBMODULES=ON \ |
| 73 | + -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -DNDEBUG' |
| 74 | + make -C build/ all |
| 75 | + - name: Test |
| 76 | + run: | |
| 77 | + cd zip-check/FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}/FreeRTOS-Cellular-Interface/build/ |
| 78 | + ctest -E system --output-on-failure |
| 79 | + cd .. |
| 80 | + - name: Create artifact of ZIP |
| 81 | + uses: actions/upload-artifact@v2 |
| 82 | + with: |
| 83 | + name: FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip |
| 84 | + path: zip-check/FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip |
| 85 | + create-release: |
| 86 | + needs: create-zip |
| 87 | + name: Create Release and Upload Release Asset |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + - name: Create Release |
| 91 | + id: create_release |
| 92 | + uses: actions/create-release@v1 |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + with: |
| 96 | + tag_name: ${{ github.event.inputs.version_number }} |
| 97 | + release_name: ${{ github.event.inputs.version_number }} |
| 98 | + body: Release ${{ github.event.inputs.version_number }} of the FreeRTOS-Cellular-Interface Library. |
| 99 | + draft: false |
| 100 | + prerelease: false |
| 101 | + - name: Download ZIP artifact |
| 102 | + uses: actions/download-artifact@v2 |
| 103 | + with: |
| 104 | + name: FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip |
| 105 | + - name: Upload Release Asset |
| 106 | + id: upload-release-asset |
| 107 | + uses: actions/upload-release-asset@v1 |
| 108 | + env: |
| 109 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + with: |
| 111 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 112 | + asset_path: ./FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip |
| 113 | + asset_name: FreeRTOS-Cellular-Interface-${{ github.event.inputs.version_number }}.zip |
| 114 | + asset_content_type: application/zip |
0 commit comments