Skip to content

Commit

Permalink
add github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
cormacrelf committed Sep 17, 2020
1 parent b64a7ae commit 2fcaebf
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI
on:
pull_request:
push:
branches:
# Delete whichever of these you aren't using.
- master

jobs:

# Jobs go here. Most of is article is about things
# to put in this section.
build-macos:
name: "Build on macOS"
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
# components: rustfmt, clippy
- run: cargo check

73 changes: 73 additions & 0 deletions .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Homebrew
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
homebrew:
name: "Create homebrew release"
runs-on: macos-latest
steps:
- name: Get tag
id: push
run: |
echo ::set-output name=name::${GITHUB_REF#refs/*/}
echo ::set-output name=branch::${GITHUB_REF#refs/heads/}
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- uses: actions/checkout@v2
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Run cargo build --release
uses: actions-rs/cargo@v1
with:
command: build
args: --release

- name: Homebrew archive and shasum
id: archive
run: |
cd target/release
tar -czf dark-notify-${{ steps.push.outputs.tag }}.tar.gz dark-notify
SUM=$(shasum -a 256 dark-notify-${{ steps.push.outputs.tag }}.tar.gz | awk '{print $1}')
echo "::set-output name=shasum::$SUM"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.push.outputs.tag }}
release_name: Release ${{ steps.push.outputs.tag }}
draft: false
prerelease: false

- name: Upload Release Asset
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/release/dark-notify-${{ steps.push.outputs.tag }}.tar.gz
asset_name: dark-notify-${{ steps.push.outputs.tag }}.tar.gz
asset_content_type: application/gzip

- name: Update Homebrew formula
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.BREW_TOKEN }}
run: |
brew tap cormacrelf/tap
brew bump-formula-pr -f --no-browse --no-audit \
--version='${{ steps.push.outputs.tag }}' \
--sha256='${{ steps.archive.outputs.shasum }}' \
--url='${{ steps.upload_release_asset.outputs.browser_download_url }}' \
cormacrelf/tap/dark-notify

0 comments on commit 2fcaebf

Please sign in to comment.