|
| 1 | +name: Package Tasks |
| 2 | + |
| 3 | +# This workflow only runs when pushing to master or pushing a tag |
| 4 | +# |
| 5 | +# On master, it will: |
| 6 | +# - Build packages for selected Debian/Ubuntu distro |
| 7 | +# - Upload the packages to https://dl.bintray.com/gergondet/multi-contact-head |
| 8 | +# |
| 9 | +# On tagged versions it will: |
| 10 | +# - Create a GitHub release draft |
| 11 | +# - Attach the sources to the release |
| 12 | +# - Build packages for selected Debian/Ubuntu distro |
| 13 | +# - Upload the packages to https://dl.bintray.com/gergondet/multi-contact |
| 14 | +# - Finalize the release |
| 15 | + |
| 16 | +on: |
| 17 | + push: |
| 18 | + branches: |
| 19 | + - master |
| 20 | + tags: |
| 21 | + - v* |
| 22 | + |
| 23 | +jobs: |
| 24 | + # For a given tag vX.Y.Z, this checks: |
| 25 | + # - set(PROJECT_VERSION X.Y.Z) in CMakeLists.txt |
| 26 | + # - version X.Y.Z in debian/changelog |
| 27 | + # If these checks fail, the tag is automatically deleted |
| 28 | + # |
| 29 | + # This job does not run on the master branch |
| 30 | + check-tag: |
| 31 | + runs-on: ubuntu-18.04 |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v1 |
| 34 | + with: |
| 35 | + submodules: recursive |
| 36 | + if: github.ref != 'refs/heads/master' |
| 37 | + - name: Check version coherency |
| 38 | + run: | |
| 39 | + set -x |
| 40 | + export VERSION=`echo ${{ github.ref }} | sed -e 's@refs/tags/v@@'` |
| 41 | + echo "::set-env name=REJECTION::PROJECT_VERSION in CMakeLists.txt does not match tag" |
| 42 | + grep -q "set(PROJECT_VERSION ${VERSION})" CMakeLists.txt |
| 43 | + echo "::set-env name=REJECTION::Upstream version in debian/changelog does not match tag" |
| 44 | + head -n 1 debian/changelog | grep -q "tasks (${VERSION}" |
| 45 | + echo "::set-env name=REJECTION::" |
| 46 | + export TAG=`echo ${{ github.ref }} | sed -e 's@refs/tags/@@'` |
| 47 | + echo "::set-env name=RELEASE_TAG::${TAG}" |
| 48 | + if: github.ref != 'refs/heads/master' |
| 49 | + - name: Delete tag |
| 50 | + run: | |
| 51 | + set -x |
| 52 | + curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X DELETE https://api.github.com/repos/${{ github.repository }}/git/${{ github.ref }} |
| 53 | + if: failure() |
| 54 | + - name: Notify tag deletion |
| 55 | + uses: archive/github-actions-slack@master |
| 56 | + with: |
| 57 | + slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_TOKEN }} |
| 58 | + slack-channel: '#ci' |
| 59 | + slack-text: > |
| 60 | + Tag *${{ github.ref }}* in *${{ github.repository }}* was deleted: |
| 61 | + ${{ env.REJECTION}} |
| 62 | + if: failure() |
| 63 | + - name: Create release |
| 64 | + uses: jrl-umi3218/github-actions/create-release@master |
| 65 | + with: |
| 66 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + tag: ${{ env.RELEASE_TAG }} |
| 68 | + if: github.ref != 'refs/heads/master' |
| 69 | + # This job build binary packages for Ubuntu |
| 70 | + build-packages: |
| 71 | + needs: check-tag |
| 72 | + strategy: |
| 73 | + fail-fast: false |
| 74 | + matrix: |
| 75 | + dist: [xenial, bionic, focal] |
| 76 | + arch: [i386, amd64] |
| 77 | + runs-on: ubuntu-18.04 |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v1 |
| 80 | + - name: Prepare recipe |
| 81 | + run: | |
| 82 | + set -x |
| 83 | + cp .github/workflows/Tasks.recipe /tmp/Tasks.recipe |
| 84 | + export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'` |
| 85 | + sed -i "s#@REF@#${REF}#" /tmp/Tasks.recipe |
| 86 | + if [ $REF == "master" ] |
| 87 | + then |
| 88 | + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-head" |
| 89 | + else |
| 90 | + echo "::set-env name=EXTRA_MIRROR::https://dl.bintray.com/gergondet/multi-contact-release" |
| 91 | + fi |
| 92 | + echo "Prepared recipe" |
| 93 | + echo "###############" |
| 94 | + cat /tmp/Tasks.recipe |
| 95 | + - name: Build package |
| 96 | + uses: jrl-umi3218/github-actions/build-package@master |
| 97 | + with: |
| 98 | + dist: ${{ matrix.dist }} |
| 99 | + arch: ${{ matrix.arch }} |
| 100 | + recipe: /tmp/Tasks.recipe |
| 101 | + other-mirrors: ${{ env.EXTRA_MIRROR }} |
| 102 | + other-gpg-keys: "0x892EA6EE273707C6495A6FB6220D644C64666806" |
| 103 | + - uses: actions/upload-artifact@v1 |
| 104 | + with: |
| 105 | + name: packages-${{ matrix.dist }}-${{ matrix.arch }} |
| 106 | + path: /tmp/packages-${{ matrix.dist }}-${{ matrix.arch }}/ |
| 107 | + # This job upload binary packages for Ubuntu |
| 108 | + upload-packages: |
| 109 | + needs: build-packages |
| 110 | + strategy: |
| 111 | + max-parallel: 1 |
| 112 | + fail-fast: false |
| 113 | + matrix: |
| 114 | + dist: [xenial, bionic, focal] |
| 115 | + arch: [i386, amd64] |
| 116 | + runs-on: ubuntu-18.04 |
| 117 | + steps: |
| 118 | + - name: Set upload parameters |
| 119 | + run: | |
| 120 | + export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'` |
| 121 | + if [ $REF == "master" ] |
| 122 | + then |
| 123 | + echo "::set-env name=BINTRAY_REPO::multi-contact-head" |
| 124 | + echo "::set-env name=BINTRAY_VERSION::HEAD" |
| 125 | + else |
| 126 | + echo "::set-env name=BINTRAY_REPO::multi-contact-release" |
| 127 | + echo "::set-env name=BINTRAY_VERSION::${REF}" |
| 128 | + fi |
| 129 | + - name: Download packages |
| 130 | + uses: actions/download-artifact@v1 |
| 131 | + with: |
| 132 | + name: packages-${{ matrix.dist }}-${{ matrix.arch }} |
| 133 | + - name: Upload |
| 134 | + uses: jrl-umi3218/github-actions/upload-package@master |
| 135 | + with: |
| 136 | + dist: ${{ matrix.dist }} |
| 137 | + arch: ${{ matrix.arch }} |
| 138 | + subject: gergondet |
| 139 | + repo: ${{ env.BINTRAY_REPO }} |
| 140 | + package: | |
| 141 | + name: Tasks |
| 142 | + desc: "Real-time contorl for kinematics tree and list of kinematics tree" |
| 143 | + licenses: [BSD 2-Clause] |
| 144 | + vcs_url: https://github.com/jrl-umi3218/Tasks |
| 145 | + version: ${{ env.BINTRAY_VERSION }} |
| 146 | + path: packages-${{ matrix.dist }}-${{ matrix.arch }} |
| 147 | + BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} |
| 148 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
0 commit comments