| 
 | 1 | +on:  | 
 | 2 | +  push:  | 
 | 3 | +    tags:  | 
 | 4 | +      - "v*" # Run when tag matches v*, i.e. v1.0, v20.15.10  | 
 | 5 | + | 
 | 6 | +name: Release  | 
 | 7 | + | 
 | 8 | +env:  | 
 | 9 | +  RELEASE_BIN: matched-data-cli  | 
 | 10 | +  RELEASE_DIR: artifacts  | 
 | 11 | +  GITHUB_REF: "${{ github.ref }}"  | 
 | 12 | +  WINDOWS_TARGET: x86_64-pc-windows-msvc  | 
 | 13 | +  MACOS_TARGET: x86_64-apple-darwin  | 
 | 14 | +  LINUX_TARGET: x86_64-unknown-linux-musl  | 
 | 15 | + | 
 | 16 | +  # Space separated paths to include in the archive.  | 
 | 17 | +  RELEASE_ADDS: README.md  | 
 | 18 | + | 
 | 19 | +jobs:  | 
 | 20 | +  build:  | 
 | 21 | +    name: Build artifacts  | 
 | 22 | +    runs-on: ${{ matrix.os }}  | 
 | 23 | +    strategy:  | 
 | 24 | +      matrix:  | 
 | 25 | +        build: [linux, macos, windows]  | 
 | 26 | +        include:  | 
 | 27 | +          - build: linux  | 
 | 28 | +            os: ubuntu-latest  | 
 | 29 | +            rust: stable  | 
 | 30 | +          - build: macos  | 
 | 31 | +            os: macos-latest  | 
 | 32 | +            rust: stable  | 
 | 33 | +          - build: windows  | 
 | 34 | +            os: windows-latest  | 
 | 35 | +            rust: stable  | 
 | 36 | + | 
 | 37 | +    steps:  | 
 | 38 | +      - uses: actions/checkout@v2  | 
 | 39 | + | 
 | 40 | +      - name: Query version number  | 
 | 41 | +        id: get_version  | 
 | 42 | +        shell: bash  | 
 | 43 | +        run: |  | 
 | 44 | +          echo "using version tag ${GITHUB_REF:10}"  | 
 | 45 | +          echo ::set-output name=version::"${GITHUB_REF:10}"  | 
 | 46 | +
  | 
 | 47 | +      - name: Install Rust  | 
 | 48 | +        if: matrix.rust  | 
 | 49 | +        run: |  | 
 | 50 | +          rustup update ${{ matrix.rust }} --no-self-update  | 
 | 51 | +          rustup default ${{ matrix.rust }}  | 
 | 52 | +
  | 
 | 53 | +      - name: Install musl-tools (Linux)  | 
 | 54 | +        if: matrix.build == 'linux'  | 
 | 55 | +        run: |  | 
 | 56 | +          sudo apt-get update -y  | 
 | 57 | +          sudo apt-get install musl-tools -y  | 
 | 58 | +
  | 
 | 59 | +      - name: Install p7zip (MacOS)  | 
 | 60 | +        if: matrix.build == 'macos'  | 
 | 61 | +        run: brew install p7zip  | 
 | 62 | + | 
 | 63 | +      - name: Build (Linux)  | 
 | 64 | +        if: matrix.build == 'linux'  | 
 | 65 | +        run: |  | 
 | 66 | +          rustup target add ${{ env.LINUX_TARGET }}  | 
 | 67 | +          cargo build --release --target ${{ env.LINUX_TARGET }}  | 
 | 68 | +
  | 
 | 69 | +      - name: Build (MacOS)  | 
 | 70 | +        if: matrix.build == 'macos'  | 
 | 71 | +        run: cargo build --release  | 
 | 72 | + | 
 | 73 | +      - name: Build (Windows)  | 
 | 74 | +        if: matrix.build == 'windows'  | 
 | 75 | +        run: cargo build --release  | 
 | 76 | +        env:  | 
 | 77 | +          RUSTFLAGS: -Ctarget-feature=+crt-static  | 
 | 78 | + | 
 | 79 | +      - name: Create artifact directory  | 
 | 80 | +        run: |  | 
 | 81 | +          mkdir ${{ env.RELEASE_DIR }}  | 
 | 82 | +          mkdir dist  | 
 | 83 | +
  | 
 | 84 | +      - name: Create tarball (Linux)  | 
 | 85 | +        if: matrix.build == 'linux'  | 
 | 86 | +        run: |  | 
 | 87 | +          mv ./target/${{ env.LINUX_TARGET }}/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}  | 
 | 88 | +          mv ${{ env.RELEASE_ADDS }} ./dist  | 
 | 89 | +          7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.tar.gz  | 
 | 90 | +
  | 
 | 91 | +      - name: Create tarball (Windows)  | 
 | 92 | +        if: matrix.build == 'windows'  | 
 | 93 | +        shell: bash  | 
 | 94 | +        run: |  | 
 | 95 | +          mv ./target/release/${{ env.RELEASE_BIN }}.exe ./dist/${{ env.RELEASE_BIN }}.exe  | 
 | 96 | +          mv ${{ env.RELEASE_ADDS }} ./dist  | 
 | 97 | +          7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.tar.gz  | 
 | 98 | +
  | 
 | 99 | +      - name: Create tarball (MacOS)  | 
 | 100 | +        if: matrix.build == 'macos'  | 
 | 101 | +        run: |  | 
 | 102 | +          mv ./target/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}  | 
 | 103 | +          mv ${{ env.RELEASE_ADDS }} ./dist  | 
 | 104 | +          7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.tar.gz  | 
 | 105 | +
  | 
 | 106 | +      - name: Upload Zip  | 
 | 107 | +        uses: actions/upload-artifact@v1  | 
 | 108 | +        with:  | 
 | 109 | +          name: ${{ matrix.build }}  | 
 | 110 | +          path: ./${{ env.RELEASE_DIR }}  | 
 | 111 | + | 
 | 112 | +  release:  | 
 | 113 | +    name: GitHub Release  | 
 | 114 | +    needs: build  | 
 | 115 | +    runs-on: ubuntu-latest  | 
 | 116 | +    steps:  | 
 | 117 | +      - name: Query version number  | 
 | 118 | +        id: get_version  | 
 | 119 | +        shell: bash  | 
 | 120 | +        run: |  | 
 | 121 | +          echo "using version tag ${GITHUB_REF:10}"  | 
 | 122 | +          echo ::set-output name=version::"${GITHUB_REF:10}"  | 
 | 123 | +
  | 
 | 124 | +      - name: Create Release  | 
 | 125 | +        id: create_release  | 
 | 126 | +        uses: actions/create-release@v1  | 
 | 127 | +        env:  | 
 | 128 | +          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
 | 129 | +        with:  | 
 | 130 | +          tag_name: ${{ steps.get_version.outputs.VERSION }}  | 
 | 131 | +          release_name: ${{ steps.get_version.outputs.VERSION }}  | 
 | 132 | + | 
 | 133 | +      - name: Download Linux tarball  | 
 | 134 | +        uses: actions/download-artifact@v1  | 
 | 135 | +        with:  | 
 | 136 | +          name: linux  | 
 | 137 | + | 
 | 138 | +      - name: Download MacOS tarball  | 
 | 139 | +        uses: actions/download-artifact@v1  | 
 | 140 | +        with:  | 
 | 141 | +          name: windows  | 
 | 142 | + | 
 | 143 | +      - name: Download MacOS tarball  | 
 | 144 | +        uses: actions/download-artifact@v1  | 
 | 145 | +        with:  | 
 | 146 | +          name: macos  | 
 | 147 | + | 
 | 148 | +      - name: Release Linux tarball  | 
 | 149 | +        uses: actions/upload-release-asset@v1  | 
 | 150 | +        env:  | 
 | 151 | +          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
 | 152 | +        with:  | 
 | 153 | +          upload_url: ${{ steps.create_release.outputs.upload_url }}  | 
 | 154 | +          asset_path: ./linux/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.tar.gz  | 
 | 155 | +          asset_content_type: application/gzip  | 
 | 156 | +          asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.tar.gz  | 
 | 157 | + | 
 | 158 | +      - name: Release Windows tarball  | 
 | 159 | +        uses: actions/upload-release-asset@v1  | 
 | 160 | +        env:  | 
 | 161 | +          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
 | 162 | +        with:  | 
 | 163 | +          upload_url: ${{ steps.create_release.outputs.upload_url }}  | 
 | 164 | +          asset_path: ./windows/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.tar.gz  | 
 | 165 | +          asset_content_type: application/gzip  | 
 | 166 | +          asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.tar.gz  | 
 | 167 | + | 
 | 168 | +      - name: Release MacOS tarball  | 
 | 169 | +        uses: actions/upload-release-asset@v1  | 
 | 170 | +        env:  | 
 | 171 | +          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
 | 172 | +        with:  | 
 | 173 | +          upload_url: ${{ steps.create_release.outputs.upload_url }}  | 
 | 174 | +          asset_path: ./macos/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.tar.gz  | 
 | 175 | +          asset_content_type: application/gzip  | 
 | 176 | +          asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.tar.gz  | 
0 commit comments