summaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: 2b9f3d2f92dff16e0a02cf409e169e1d85eea906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Release

on:
  push:
    tags:
      - "*"

jobs:
  release:
    name: Release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macOS-latest, windows-latest, ubuntu-latest]
        include:
          - os: macOS-latest
            archive: tar
            output: streamlib-${{ github.sha }}-x86_64-apple-darwin.tar.gz
            content_type: 'application/gzip'
          - os: windows-latest
            archive: zip
            output: streamlib-${{ github.sha }}-x86_64-pc-windows-msvc.zip
            content_type: application/zip
          - os: ubuntu-latest
            archive: tar
            output: streamlib-${{ github.sha }}-x86_64-unknown-linux-gnu.tar.gz
            content_type: application/gzip

    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Install toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable

      - name: Build
        run: cargo build --verbose --release

      - name: Test
        run: cargo test --verbose

      - name: Build ZIP
        id: build_zip
        if: matrix.archive == 'zip'
        run: |
          cp target/release/foo.exe .
          7z a ${{ matrix.output }} target/release/foo.exe

      - name: Build TAR
        id: build_tar
        if: matrix.archive == 'tar'
        run: |
          cp target/release/foo .
          tar czvf ${{ matrix.output }} target/release/foo

      - name: Create Release
        id: create_release
        uses: actions/create-release@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: true # for now we only do pre-releases

      - name: Upload Release Asset
        id: upload-release-asset
        uses: actions/upload-release-asset@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./${{ matrix.output }}
          asset_name: ${{ matrix.output }}
          asset_content_type: ${{ matrix.content_type }}