Skip to content

Commit

Permalink
seperate test & release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruggem committed Feb 6, 2020
1 parent df6ad63 commit f444181
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 20 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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/[email protected]
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
30 changes: 10 additions & 20 deletions .github/workflows/rust.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Build and test
name: Test

on: [push]
on:
push:
branches:
- "*"
tags-ignore:
- "v*"

jobs:
build:
Expand All @@ -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
Expand Down Expand Up @@ -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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false

0 comments on commit f444181

Please sign in to comment.