Skip to content

Commit

Permalink
Testing release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Sep 1, 2021
1 parent e62376b commit 7329d9d
Showing 1 changed file with 142 additions and 0 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Based on: https://github.com/ClementTsang/bottom/blob/master/.github/workflows/deployment.yml

name: Release

on:
push:
tags:
- v*

env:
CARGO_TERM_COLOR: always

jobs:
# publish-crate:
# name: Publish Crate
# runs-on: ubuntu-20.04
# defaults:
# run:
# working-directory: ./pagebreak
# steps:
# - name: Clone
# uses: actions/checkout@v2
# - name: Cache
# uses: actions/cache@v2
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# ~/.rustup
# target
# key: ${{ runner.os }}-stable
# - name: Setup
# run: |
# rustup install stable
# - name: Build
# run: cargo build --verbose
# - name: Run tests
# run: cargo test
# - name: Publish
# run: cargo publish
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

publish-to-github:
name: Publish to Github
runs-on: ${{matrix.os}}
defaults:
run:
working-directory: ./pagebreak
strategy:
matrix:
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
cross: false
- build: arm-v7
os: ubuntu-latest
rust: stable
target: armv7-unknown-linux-gnueabihf
linker: gcc-arm-linux-gnueabihf
cross: true
- build: aarch64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
linker: gcc-aarch64-linux-gnu
cross: true
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-${{ matrix.rust }}

- name: Install Linker
if: matrix.cross
run: |
sudo apt update
sudo apt install ${{ matrix.linker }}
- name: Install Rust
run: |
rustup install ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
rustup show
- name: Build
run: cargo build --release --target ${{ matrix.target }}

- name: Package Artifacts
run: |
src=$(pwd)
stage=
case $RUNNER_OS in
Linux)
stage=$(mktemp -d)
;;
macOS)
stage=$(mktemp -d -t tmp)
;;
esac
cp target/${{ matrix.target }}/release/pagebreak $stage/
cd $stage
RELEASE_VERSION=${GITHUB_REF#refs/tags/}
ASSET_NAME="pagebreak-$RELEASE_VERSION-${{ matrix.target }}.tar.gz"
ASSET_PATH="$src/$ASSET_NAME"
CHECKSUM_PATH="$ASSET_PATH.sha256"
echo "ASSET_PATH=$ASSET_PATH" >> $GITHUB_ENV
echo "CHECKSUM_PATH=$CHECKSUM_PATH" >> $GITHUB_ENV
tar czf $ASSET_PATH *
cd $src
case $RUNNER_OS in
Linux)
sha256sum $ASSET_NAME > $CHECKSUM_PATH
;;
macOS)
shasum -a 256 $ASSET_NAME > $CHECKSUM_PATH
;;
esac
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ env.ASSET_PATH }}
${{ env.CHECKSUM_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 7329d9d

Please sign in to comment.