Skip to content

Commit

Permalink
Added ci
Browse files Browse the repository at this point in the history
  • Loading branch information
eras committed Oct 10, 2022
1 parent 60eb40c commit f1cae67
Show file tree
Hide file tree
Showing 2 changed files with 210 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build

on: [push]

jobs:
notify_start:
runs-on: ubuntu-latest
steps:
- name: Build started notification
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "midihidi ${{ github.sha }} build started. [Progress.](https://github.com/eras/midihidi/actions/runs/${{github.run_id}})"
server: ${{ secrets.MATRIX_SERVER }}
build:
needs: notify_start
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install build deps
run: sudo apt-get install git libjack-dev
if: ${{ matrix.os == 'ubuntu-latest' }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: 'cargo build'
- uses: actions/upload-artifact@v2
with:
name: midihidi-${{ runner.os }}
path: |
target/debug/midihidi
Cargo.lock
if: ${{ matrix.os != 'windows-latest' }}
- uses: actions/upload-artifact@v2
with:
name: midihidi-${{ runner.os }}.exe
path: |
target/debug/midihidi.exe
Cargo.lock
if: ${{ matrix.os == 'windows-latest' }}
notify_end_success:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: [notify_start, build]
steps:
- name: Build succeeded notification
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "midihidi ${{ github.sha }} build complete OK. [Logs.](https://github.com/eras/midihidi/actions/runs/${{github.run_id}})"
server: ${{ secrets.MATRIX_SERVER }}
notify_end_failed:
runs-on: ubuntu-latest
needs: [notify_start, build]
if: ${{ !success() }}
steps:
- name: Build failed notification
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "midihidi ${{ github.sha }} build failed. [Logs.](https://github.com/eras/midihidi/actions/runs/${{github.run_id}})"
server: ${{ secrets.MATRIX_SERVER }}
131 changes: 131 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
on:
push:
tags:
- 'v*'

name: tag
jobs:
create_release:
name: Create release
permissions:
issues: write
pull-requests: write
contents: write
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
git_describe: ${{ steps.git_describe.outputs.git_describe }}
git_message: ${{ steps.git_message.outputs.git_message }}
steps:
# https://github.com/actions/create-release
- uses: actions/checkout@v2
with:
submodules: true
# https://stackoverflow.com/a/58178121
- name: Set release information
id: git_describe
run: echo ::set-output name=git_describe::"$(git describe --tags)"
# https://stackoverflow.com/a/58178121
- name: Build started notification
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "midihidi release ${{ steps.git_describe.outputs.git_describe }} build started. [Progress.](https://github.com/eras/midihidi/actions/runs/${{github.run_id}})"
server: ${{ secrets.MATRIX_SERVER }}
- name: Cancel if no tag
if: ${{ steps.git_describe.outputs.git_describe == '' }}
run: false
- name: Set annotated tag info information
id: git_message
run: echo ::set-output name=git_message::"$(git tag -n999 -l $(git describe --tags))"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.git_message.outputs.git_message }}
draft: false
prerelease: false
unix:
name: midihidi
needs: create_release
permissions:
issues: write
pull-requests: write
contents: write
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install build deps
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install git libjack-dev
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: build
env:
GIT_DESCRIBE: ${{ needs.create_release.outputs.git_describe }}
run: 'cargo build --release --frozen'
- run: strip target/release/midihidi
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
- uses: actions/upload-artifact@v2
with:
name: midihidi
path: |
target/release/midihidi
Cargo.lock
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
# https://github.com/actions/upload-release-asset
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./target/release/midihidi
asset_name: midihidi-${{ needs.create_release.outputs.git_describe }}-${{ runner.os }}.bin
asset_content_type: application/octet-stream
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
notify_end_success:
runs-on: ubuntu-latest
needs: [create_release, unix]
if: ${{ success() }}
steps:
- name: Build succeeded notification
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "midihidi release ${{ needs.create_release.outputs.git_describe }} build complete. [Logs.](https://github.com/eras/midihidi/actions/runs/${{github.run_id}})"
server: ${{ secrets.MATRIX_SERVER }}
notify_end_failed:
runs-on: ubuntu-latest
needs: [create_release, unix]
if: ${{ !success() }}
steps:
- name: Build failed notification
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: "midihidi release ${{ needs.create_release.outputs.git_describe }} build failed. [Logs.](https://github.com/eras/midihidi/actions/runs/${{github.run_id}})"
server: ${{ secrets.MATRIX_SERVER }}

0 comments on commit f1cae67

Please sign in to comment.