Skip to content

Commit

Permalink
Adding auto release yaml to publish binaries with tags
Browse files Browse the repository at this point in the history
  • Loading branch information
x0a1b committed Jun 27, 2020
1 parent 2704a37 commit 07712df
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Build Release
env:
# Could, potentially automatically parse
# the bin name, but let's do it automatically for now.
RELEASE_BIN: drep

# Space separated paths to include in the archive.
# Start relative paths with a dot if you don't want
# paths to be preserved. Use "/" as a delimiter.
RELEASE_ADDS: README.md LICENSE example_filters

jobs:
build:
name: Build release
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
rust: stable
- build: macos
os: macos-latest
rust: stable
- build: windows
os: windows-latest
rust: stable

steps:
- uses: actions/checkout@v2

- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
if: matrix.os != 'macos-latest'
shell: bash

- name: Install Rust (macos)
# As of 7.12.2019 rust is not installed on MacOS
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners#macos-1015
run: |
curl https://sh.rustup.rs | sh -s -- -y
echo "##[add-path]$HOME/.cargo/bin"
if: matrix.os == 'macos-latest'

- name: Build
run: cargo build --verbose --release

- name: Create artifact directory
run: mkdir artifacts

- name: Create archive for Linux
run: 7z a -ttar -so -an ./target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }} | 7z a -si ./artifacts/${{ env.RELEASE_BIN }}-linux-x86_64.tar.gz
if: matrix.os == 'ubuntu-latest'

- name: Create archive for Windows
run: 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-windows-x86_64.zip ./target/release/${{ env.RELEASE_BIN }}.exe ${{ env.RELEASE_ADDS }}
if: matrix.os == 'windows-latest'

- name: Install p7zip
# 7Zip not available on MacOS, install p7zip via homebrew.
run: brew install p7zip
if: matrix.os == 'macos-latest'

- name: Create archive for MacOS
run: 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-mac-x86_64.zip ./target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }}
if: matrix.os == 'macos-latest'

- name: Upload artifacts archive
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.build }}
path: artifacts/
release:
name: Publish release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
- name: Download linux artifacts
uses: actions/download-artifact@v2
with:
name: linux
- name: Download mac artifacts
uses: actions/download-artifact@v2
with:
name: macos
- name: Download windows artifacts
uses: actions/download-artifact@v2
with:
name: windows
- name: Display structure of downloaded files
run: ls -R
- name: Release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
files: |
*.zip
*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 07712df

Please sign in to comment.