Skip to content

Instantly share code, notes, and snippets.

@ritesh
Created June 19, 2020 19:28
Show Gist options
  • Save ritesh/a91f3b699042e56c8441218a25191535 to your computer and use it in GitHub Desktop.
Save ritesh/a91f3b699042e56c8441218a25191535 to your computer and use it in GitHub Desktop.
name: CI
on:
push:
branches:
- master
tags:
- '*'
jobs:
testbuild:
name: Testing build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
include:
- os: ubuntu-latest
rust: stable
buildcmd: "make cfn-guard"
target: x86_64-unknown-linux-gnu
bin: cfn-guard
name: cfn-guard-Linux-x86_64.tar.gz
- os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
buildcmd: "cd cfn-guard && cargo build --release"
bin: cfn-guard.exe
name: cfn-guard-Windows-x86_64.zip
- os: macOS-latest
rust: stable
buildcmd: "make cfn-guard"
target: x86_64-apple-darwin
bin: cfn-guard
name: cfn-guard-Darwin-x86_64.tar.gz
steps:
- uses: actions/checkout@v1
- name: Running on {{ matrix.os }}
uses: actions-rs/toolchain@v1
with:
override: true
toolchain: stable
target: ${{ matrix.target }}
- run: ${{ matrix.buildcmd }}
cutrelease:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release for ${{ github.ref }}
draft: false
prerelease: false
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_artifacts:
needs: cutrelease
name: Creating artifacts for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
include:
- os: ubuntu-latest
rust: stable
buildcmd: "make cfn-guard"
pkgcmd: "strip ./bin/cfn-guard && tar -C ./bin -czvf cfn-guard-Linux-x86_64.tar.gz cfn-guard"
target: x86_64-unknown-linux-gnu
bin: cfn-guard
name: cfn-guard-Linux-x86_64.tar.gz
asset_path: "./cfn-guard-Linux-x86_64.tar.gz"
mime: "application/tar+gzip"
- os: macOS-latest
rust: stable
buildcmd: "make cfn-guard"
pkgcmd: "strip ./bin/cfn-guard && tar -C ./bin -czvf cfn-guard-Darwin-x86_64.tar.gz cfn-guard"
target: x86_64-apple-darwin
bin: cfn-guard
name: cfn-guard-Darwin-x86_64.tar.gz
mime: application/tar+gzip
asset_path: "./cfn-guard-Darwin-x86_64.tar.gz"
steps:
- name: Code checkout
uses: actions/checkout@v2
- name: Code build
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: ${{ matrix.buildcmd }}
- name: Package
id: package_artifacts
shell: bash
run: ${{ matrix.pkgcmd }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.cutrelease.outputs.upload_url }}
asset_name: ${{ matrix.name }}
asset_content_type: ${{ matrix.mime }}
asset_path: ${{ matrix.asset_path }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment