|
| 1 | +on: |
| 2 | + push: |
| 3 | + paths: |
| 4 | + - 'VERSION' |
| 5 | + branches: master |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-and-package: |
| 9 | + name: Build nesto-usbproxy debian package |
| 10 | + runs-on: ubuntu-latest |
| 11 | + container: |
| 12 | + image: ghcr.io/${{ github.repository_owner }}/nesto-usbproxy-deps:latest |
| 13 | + credentials: |
| 14 | + username: ${{ github.repository_owner }} |
| 15 | + password: ${{ secrets.CR_PAT }} |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + with: |
| 20 | + path: 'usbproxy' |
| 21 | + ref: 'dev' |
| 22 | + |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + with: |
| 25 | + repository: fsaintjacques/semver-tool |
| 26 | + path: semver |
| 27 | + |
| 28 | + - name: Build semver utility |
| 29 | + run: | |
| 30 | + cd semver && make install |
| 31 | +
|
| 32 | + - name: Create build directory |
| 33 | + run: | |
| 34 | + mkdir -p usbproxy/src/build |
| 35 | +
|
| 36 | + - name: Create Makefiles using CMake |
| 37 | + working-directory: usbproxy/src/build |
| 38 | + run: | |
| 39 | + LDFLAGS="-L${STAGING_DIR}/usr/local/lib" \ |
| 40 | + CFLAGS="-I${STAGING_DIR}/usr/local/include" \ |
| 41 | + CXXFLAGS=$CFLAGS \ |
| 42 | + PKG_CONFIG_PATH=$STAGING_DIR/usr/local/lib/pkgconfig \ |
| 43 | + cmake \ |
| 44 | + "-DCMAKE_PREFIX_PATH=$STAGING_DIR/usr/local" \ |
| 45 | + "-DCMAKE_FIND_ROOT_PATH=$STAGING_DIR" \ |
| 46 | + "-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_FILE" \ |
| 47 | + "-DCMAKE_INSTALL_PREFIX=/usr" \ |
| 48 | + "-DCMAKE_BUILD_TYPE=Release" \ |
| 49 | + "-DUSE_LIBUSB1=1" \ |
| 50 | + .. |
| 51 | +
|
| 52 | + - name: Run make |
| 53 | + working-directory: usbproxy/src/build |
| 54 | + run: | |
| 55 | + make |
| 56 | +
|
| 57 | + - name: Run make install |
| 58 | + working-directory: usbproxy/src/build |
| 59 | + run: | |
| 60 | + DESTDIR=${ROOT_FS} make install |
| 61 | +
|
| 62 | + - name: Read the package version |
| 63 | + working-directory: usbproxy |
| 64 | + id: version |
| 65 | + run: | |
| 66 | + NEW_VERSION=$(cat ./VERSION) |
| 67 | + echo "::set-output name=NEW_VERSION::$NEW_VERSION" |
| 68 | +
|
| 69 | + - name: Build the debian package |
| 70 | + working-directory: usbproxy/src |
| 71 | + run: | |
| 72 | + dpkg-buildpackage -d -aarmhf -tarm-rpi-linux-gnueabihf |
| 73 | +
|
| 74 | + - name: Archive production artifacts |
| 75 | + uses: actions/upload-artifact@v2 |
| 76 | + with: |
| 77 | + name: debian-package |
| 78 | + path: | |
| 79 | + usbproxy/*.deb |
| 80 | +
|
| 81 | + - name: Push a new tag |
| 82 | + id: tag_version |
| 83 | + uses: mathieudutour/github-tag-action@v5.1 |
| 84 | + with: |
| 85 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + custom_tag: "${{ steps.version.outputs.NEW_VERSION }}" |
| 87 | + |
| 88 | + - name: Create a GitHub release |
| 89 | + uses: actions/create-release@v1 |
| 90 | + id: create_release |
| 91 | + env: |
| 92 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + with: |
| 94 | + tag_name: ${{ steps.tag_version.outputs.new_tag }} |
| 95 | + release_name: Release ${{ steps.tag_version.outputs.new_tag }} |
| 96 | + body: "Signed-off-by: ${{ github.actor }}" |
| 97 | + |
| 98 | + - name: Compress the release asset |
| 99 | + run: | |
| 100 | + tar -cvjSf nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.tar.bz2 usbproxy/nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.deb |
| 101 | +
|
| 102 | + - name: Upload Release Asset - Debian Package |
| 103 | + uses: actions/upload-release-asset@v1 |
| 104 | + id: upload-release-asset |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + with: |
| 108 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 109 | + asset_path: usbproxy/nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.deb |
| 110 | + asset_name: nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.deb |
| 111 | + asset_content_type: application/vnd.debian.binary-package |
| 112 | + |
| 113 | + - name: Upload Release Asset - Archive |
| 114 | + uses: actions/upload-release-asset@v1 |
| 115 | + id: upload-release-asset-archive |
| 116 | + env: |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + with: |
| 119 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 120 | + asset_path: nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.tar.bz2 |
| 121 | + asset_name: nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.tar.bz2 |
| 122 | + asset_content_type: application/vnd.debian.binary-package |
| 123 | + |
| 124 | + upload-package: |
| 125 | + name: Upload nesto-usbproxy debian package into nesto repository in S3 |
| 126 | + runs-on: ubuntu-latest |
| 127 | + needs: build-and-package |
| 128 | + container: |
| 129 | + image: ghcr.io/${{ github.repository_owner }}/aptly:latest |
| 130 | + credentials: |
| 131 | + username: ${{ github.repository_owner }} |
| 132 | + password: ${{ secrets.CR_PAT }} |
| 133 | + |
| 134 | + steps: |
| 135 | + - name: Download debian package from artifacts |
| 136 | + uses: actions/download-artifact@v2 |
| 137 | + with: |
| 138 | + name: debian-package |
| 139 | + |
| 140 | + - name: Add package to aptly |
| 141 | + env: |
| 142 | + APTLY_REPO: nesto-pos-adapter-devel |
| 143 | + run: | |
| 144 | + aptly repo add $APTLY_REPO nesto-usbproxy_*_armhf.deb |
| 145 | +
|
| 146 | + - name: Prepare GPG private key password |
| 147 | + env: |
| 148 | + GPG_PRIVATE_KEY_PASSWD: ${{ secrets.GPG_PRIVATE_KEY_PASSWD }} |
| 149 | + run: | |
| 150 | + echo $GPG_PRIVATE_KEY_PASSWD > ./key_passwd |
| 151 | +
|
| 152 | + - name: Import GPG key |
| 153 | + id: import_gpg |
| 154 | + uses: crazy-max/ghaction-import-gpg@v3 |
| 155 | + with: |
| 156 | + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 157 | + passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSWD }} |
| 158 | + |
| 159 | + - name: Sign and upload to S3 |
| 160 | + env: |
| 161 | + GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} |
| 162 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 163 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 164 | + run: | |
| 165 | + aptly publish repo -batch=true -passphrase-file="./key_passwd" -gpg-key="$GPG_KEY_ID" -component=aws -distribution=nightly nesto-pos-adapter-devel s3:nesto-debian-repo-devel: |
0 commit comments