From f44418180854a0eac807aeee8f2a347141b92e3d Mon Sep 17 00:00:00 2001 From: Jehan Bruggeman Date: Wed, 5 Feb 2020 22:38:17 +0100 Subject: [PATCH] seperate test & release workflows --- .github/workflows/release.yml | 105 +++++++++++++++++++++++ .github/workflows/{rust.yml => test.yml} | 30 +++---- 2 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/release.yml rename .github/workflows/{rust.yml => test.yml} (63%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e760a42 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,105 @@ +name: Build and Release + +on: + push: + tags: + - v* + +jobs: + tests: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Cache tests + id: test-cache + uses: actions/cache@v1 + with: + path: target + key: ${{ matrix.os }}-test-cache + + - name: Run tests + run: cargo test + + create_release: + needs: [tests] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + - name: create release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Output Release URL File + run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt + - name: Save Release URL File for publish + uses: actions/upload-artifact@v1 + with: + name: release_url + path: release_url.txt + + build_and_upload: + needs: [create_release] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Cache build + id: build-cache + uses: actions/cache@v1 + with: + path: target + key: ${{ matrix.os }}-build-cache + + - name: Build + run: cargo build --release + + - name: Load Release URL File from release job + uses: actions/download-artifact@v1 + with: + name: release_url + + - name: Get Release File Name & Upload URL + id: get_release_info + shell: bash + run: | + ls -lRa + value=`cat release_url/release_url.txt` + echo ::set-output name=upload_url::$value + + - name: Upload Release Asset + if: matrix.os == 'windows-latest' + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_info.outputs.upload_url }} + asset_path: target/release/jaslog.exe + asset_name: jaslog_windows.exe + asset_content_type: application/octet-stream + + - name: Upload Release Asset + if: matrix.os != 'windows-latest' + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_info.outputs.upload_url }} + asset_path: target/release/jaslog + asset_name: jaslog_${{ matrix.os }} + asset_content_type: application/octet-stream diff --git a/.github/workflows/rust.yml b/.github/workflows/test.yml similarity index 63% rename from .github/workflows/rust.yml rename to .github/workflows/test.yml index 8a66668..038f4ad 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,11 @@ -name: Build and test +name: Test -on: [push] +on: + push: + branches: + - "*" + tags-ignore: + - "v*" jobs: build: @@ -12,12 +17,12 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Cache build - id: build-cache + - name: Cache build and tests + id: build-and-test-cache uses: actions/cache@v1 with: path: target - key: ${{ matrix.os }}-build-cache + key: ${{ matrix.os }}-build-and-test-cache - name: Run tests run: cargo test @@ -45,18 +50,3 @@ jobs: with: name: jaslog_windows.exe path: target/release/jaslog.exe - - release: - if: github.ref == 'v*' - runs-on: ubuntu-latest - steps: - - name: Create Release - id: create_release - uses: actions/create-release@v1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: true - prerelease: false