diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d4bedb0..b5340b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,93 +1,15 @@ -name: Build binary +name: Build binaries + on: - push: - tags: - - 'v*' + release: + types: [published] jobs: release: - name: release - runs-on: ubuntu-latest - outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} - steps: - - name: create a github release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: htmlq ${{ github.ref }} - draft: true - prerelease: false - - linux: - name: linux gnulibc build - runs-on: ubuntu-latest - needs: [release] - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - run: cargo build --release - - run: tar cfz htmlq_x64_linux.tar.gz -C target/release htmlq - - name: upload x64 linux gnu release - id: release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{needs.release.outputs.upload_url}} - asset_path: ./htmlq_x64_linux.tar.gz - asset_name: htmlq_x64_linux.tar.gz - asset_content_type: application/gzip - - darwin: - name: darwin - runs-on: macos-latest - needs: [release] - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - run: cargo build --release - - run: tar cfz htmlq_x64_darwin.tar.gz -C target/release htmlq - - name: upload darwin release - id: release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{needs.release.outputs.upload_url}} - asset_path: ./htmlq_x64_darwin.tar.gz - asset_name: htmlq_x64_darwin.tar.gz - asset_content_type: application/gzip - - windows: - name: windows - runs-on: windows-latest - needs: [release] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 @@ -96,24 +18,27 @@ jobs: - uses: actions/cache@v2 with: path: | - ~/.cargo/registry - ~/.cargo/git - target + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - run: cargo build --release - - name: tar it up + - name: Build release + run: cargo build --release + - name: Archive as .tar.gz (Linux) + if: matrix.os == 'ubuntu-latest' + run: tar cfz htmlq-x86_64-linux.tar.gz -C target/release htmlq + - name: Archive as .tar.gz (macOS) + if: matrix.os == 'macos-latest' + run: tar cfz htmlq-x86_64-darwin.tar.gz -C target/release htmlq + - name: Archive as .zip (Windows) + if: matrix.os == 'windows-latest' shell: bash - run: | - tar cfz htmlq_x64_win32.tar.gz -C target/release htmlq - - name: upload windows release - id: release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: 7z a -tzip -mm=Deflate htmlq-x86_64-windows.zip ./target/release/htmlq.exe + - name: Publish + uses: softprops/action-gh-release@v1 with: - upload_url: ${{needs.release.outputs.upload_url}} - asset_path: ./htmlq_x64_win32.tar.gz - asset_name: htmlq_x64_win32.tar.gz - asset_content_type: application/gzip + files: | + htmlq*.tar.gz + htmlq*.zip \ No newline at end of file