Skip to content

Commit

Permalink
Add release CI action
Browse files Browse the repository at this point in the history
  • Loading branch information
trimental committed Aug 23, 2022
1 parent ae836ab commit 2212b20
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Release

on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]

jobs:
release:
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use-cross: false

- os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false

- os: macos-latest
target: x86_64-apple-darwin
use-cross: false

- os: macos-latest
target: aarch64-apple-darwin
use-cross: false

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install packages (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
ci/ubuntu-install-packages
- name: Set the version
id: version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}


- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: --target ${{ matrix.target }} --release --locked

- name: Strip binary
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: strip target/${{ matrix.target }}/release/inlyne

- name: Build archive
shell: bash
run: |
staging="inlyne-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"
cp {README.md,LICENSE,example.png,inlyne.toml.sample} "$staging/"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.target }}/release/inlyne.exe" "$staging/"
7z a "$staging.zip" "$staging"
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "target/${{ matrix.target }}/release/inlyne" "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
tag: ${{ github.ref }}
15 changes: 15 additions & 0 deletions ci/ubuntu-install-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# This script gets run in weird environments that have been stripped of just
# about every inessential thing. In order to keep this script versatile, we
# just install 'sudo' and use it like normal if it doesn't exist. If it doesn't
# exist, we assume we're root. (Otherwise we ain't doing much of anything
# anyway.)
if ! command -V sudo; then
apt-get update
apt-get install -y --no-install-recommends sudo
fi
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libfontconfig1-dev \
jq

0 comments on commit 2212b20

Please sign in to comment.