|
| 1 | +name: Build client packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - build_packages |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + - build_packages |
| 14 | + |
| 15 | +jobs: |
| 16 | + |
| 17 | + build-packages: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + |
| 22 | + - name: Get the version number for the packages |
| 23 | + id: get_version |
| 24 | + # If this is a tag, use the tag name (e.g. v1.2.3) without v as version number. |
| 25 | + # Otherwise, just use 0.0. |
| 26 | + run: | |
| 27 | + VERSION=0.0 |
| 28 | + REF_NAME=${{ github.ref }} |
| 29 | + [[ $REF_NAME == refs/tags/v* ]] && VERSION=${REF_NAME/refs\/tags\/v/} |
| 30 | + echo ::set-output name=version::${VERSION} |
| 31 | +
|
| 32 | + # The next step uses a custom Ansible inventory, and due to that it cannot find |
| 33 | + # the group_vars folder inside the inventory folder. This symlink fixes that. |
| 34 | + - name: Make symlink to group_vars |
| 35 | + run: ln -s inventory/group_vars |
| 36 | + |
| 37 | + - name: Prepare package source |
| 38 | + uses: roles-ansible/check-ansible-debian-stretch-action@master |
| 39 | + with: |
| 40 | + targets: "./prepare-client-packages.yml" |
| 41 | + hosts: "localhost" |
| 42 | + |
| 43 | + - name: Build RPM package |
| 44 | + id: build-rpm |
| 45 | + uses: bpicode/github-action-fpm@master |
| 46 | + with: |
| 47 | + fpm_args: "etc" |
| 48 | + fpm_opts: "--debug -n cvmfs-config-esssi -v ${{ steps.get_version.outputs.version }} -t rpm -a all -s dir -C ./package --description 'CVMFS config repository package for EESSI.'" |
| 49 | + |
| 50 | + - name: Build Deb package |
| 51 | + id: build-deb |
| 52 | + uses: bpicode/github-action-fpm@master |
| 53 | + with: |
| 54 | + fpm_args: "etc" |
| 55 | + fpm_opts: "--debug -n cvmfs-config-esssi -v ${{ steps.get_version.outputs.version }} -t deb -a all -s dir -C ./package --description 'CVMFS config repository package for EESSI.'" |
| 56 | + |
| 57 | + - name: Find filenames of downloaded packages |
| 58 | + id: find_filenames |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + rpmfile="$(ls -1 *.rpm)" |
| 62 | + debfile="$(ls -1 *.deb)" |
| 63 | + echo ::set-output name=rpmfile::${rpmfile} |
| 64 | + echo ::set-output name=debfile::${debfile} |
| 65 | +
|
| 66 | + - name: Upload Deb package as artifact |
| 67 | + uses: actions/upload-artifact@v2 |
| 68 | + with: |
| 69 | + name: Deb package |
| 70 | + path: ${{ steps.find_filenames.outputs.debfile }} |
| 71 | + |
| 72 | + - name: Upload RPM package as artifact |
| 73 | + uses: actions/upload-artifact@v2 |
| 74 | + with: |
| 75 | + name: RPM package |
| 76 | + path: ${{ steps.find_filenames.outputs.rpmfile }} |
| 77 | + |
| 78 | + release: |
| 79 | + needs: build-packages |
| 80 | + if: startsWith(github.ref, 'refs/tags/') |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - name: Download Deb package |
| 84 | + uses: actions/download-artifact@v2 |
| 85 | + with: |
| 86 | + name: Deb package |
| 87 | + |
| 88 | + - name: Download RPM package |
| 89 | + uses: actions/download-artifact@v2 |
| 90 | + with: |
| 91 | + name: RPM package |
| 92 | + |
| 93 | + - name: Find filenames of downloaded packages |
| 94 | + id: find_filenames |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + rpmfile="$(ls -1 *.rpm)" |
| 98 | + debfile="$(ls -1 *.deb)" |
| 99 | + echo ::set-output name=rpmfile::${rpmfile} |
| 100 | + echo ::set-output name=debfile::${debfile} |
| 101 | +
|
| 102 | + - name: Create Release |
| 103 | + id: create_release |
| 104 | + uses: actions/create-release@v1 |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + with: |
| 108 | + tag_name: ${{ github.ref }} |
| 109 | + release_name: Filesystem Layer ${{ github.ref }} |
| 110 | + draft: false |
| 111 | + prerelease: false |
| 112 | + |
| 113 | + - name: Upload RPM as release asset |
| 114 | + uses: actions/upload-release-asset@v1 |
| 115 | + env: |
| 116 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + with: |
| 118 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 119 | + asset_path: ${{ steps.find_filenames.outputs.rpmfile }} |
| 120 | + asset_name: ${{ steps.find_filenames.outputs.rpmfile }} |
| 121 | + asset_content_type: application/x-rpm |
| 122 | + |
| 123 | + - name: Upload Deb as release asset |
| 124 | + uses: actions/upload-release-asset@v1 |
| 125 | + env: |
| 126 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + with: |
| 128 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 129 | + asset_path: ${{ steps.find_filenames.outputs.debfile }} |
| 130 | + asset_name: ${{ steps.find_filenames.outputs.debfile }} |
| 131 | + asset_content_type: application/x-debian-package |
0 commit comments