Skip to content

Commit

Permalink
ci(workflows): redo how releases work
Browse files Browse the repository at this point in the history
  • Loading branch information
its-danny committed May 1, 2022
1 parent 8d08912 commit 02c5177
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 94 deletions.
119 changes: 80 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,93 @@ on:
- "*"

jobs:
release:
name: Release binary for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
release-to-github:
name: Release to GitHub for ${{ matrix.job.target }}
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
target:
[
x86_64-osx,
x86_64-unknown-linux-musl,
armv7-unknown-linux-musleabihf,
armv7-linux-androideabi,
aarch64-linux-android,
]
include:
- os: macos-latest
target: x86_64-osx
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: armv7-linux-androideabi
- os: ubuntu-latest
target: aarch64-linux-android
job:
- {
os: ubuntu-latest,
target: x86_64-unknown-linux-gnu,
use-cross: true,
}
- {
os: ubuntu-latest,
target: aarch64-unknown-linux-gnu,
use-cross: true,
}
- { os: macos-latest, target: x86_64-apple-darwin, use-cross: false }
- { os: macos-latest, target: aarch64-apple-darwin, use-cross: false }
- {
os: ubuntu-latest,
target: x86_64-pc-windows-gnu,
use-cross: true,
}
- {
os: windows-latest,
target: x86_64-pc-windows-msvc,
use-cross: false,
}
- {
os: windows-latest,
target: aarch64-pc-windows-msvc,
use-cross: false,
}

steps:
- name: Install libssl-dev
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get update && sudo apt-get install libssl-dev
- name: Install dependencies
shell: bash
run: |
if [[ ${{ matrix.job.target }} == "aarch64-unknown-linux-gnu" ]]; then
sudo apt update
sudo apt install -y binutils-aarch64-linux-gnu
fi
- uses: hecrj/setup-rust-action@v1
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
rust-version: stable
toolchain: stable
target: ${{ matrix.job.target }}
profile: minimal
override: true

- uses: actions/checkout@v1
- name: Build
run: meta/build.sh release ${{ matrix.target }}
- name: Checkout repository
uses: actions/checkout@v2

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
use-cross: ${{ matrix.job.use-cross }}
args: --release --target ${{ matrix.job.target }}

- name: Package final binary
shell: bash
env:
TARGET: ${{ matrix.job.target }}
PROJECT_NAME: koji
OS_NAME: ${{ matrix.job.os }}
run: ./meta/ci/package.sh

- name: Release assets
uses: softprops/action-gh-release@v1
with:
files: koji-*-${{ matrix.job.target }}.*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
release-to-cargo:
name: Release to Cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/tar/koji.tar.gz
tag: ${{ github.ref }}
asset_name: koji-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz
command: publish
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dirs = "4.0.0"
emojis = "0.4.0"
git2 = "0.14.3"
linked-hash-map = "0.5.4"
openssl-sys = { version = "0.9.72", features = [ "vendored" ] }
requestty = "0.3.0"
serde = { version = "1.0.136", features = [ "derive" ] }
toml = "0.5.9"
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-Present Danny Tatom
Copyright (c) 2021 Danny Tatom and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ for automatic versioning, changelog generation, and more

## Installation

### webi

```bash
curl -sS https://webinstall.dev/koji | bash
```

Make sure to have both [git](https://git-scm.com/) and openssl installed first.
### cargo

There are offical releases for OSX and Linux. Windows should work if you build manually,
I'm just not sure how to automate it with the current release setup.
```bash
cargo install --locked koji
```

**Note:** Refer to [this comment](https://github.com/its-danny/koji/issues/53#issuecomment-1076690486)
for getting it to work on an M1 Macbook Pro.
Be sure to have [git](https://git-scm.com/) installed first.

## Usage

Expand Down Expand Up @@ -131,4 +133,4 @@ autocomplete = true
name = "feat"
emoji = ""
description = "A new feature"
```
```
47 changes: 0 additions & 47 deletions meta/build.sh

This file was deleted.

49 changes: 49 additions & 0 deletions meta/ci/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

set -ex

pack() {
local tempdir
local out_dir
local package_name
local gcc_prefix
local extension

tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
out_dir=$(pwd)
package_name="$PROJECT_NAME-${GITHUB_REF/refs\/tags\//}-$TARGET"

if [[ $TARGET == "aarch64-unknown-linux-gnu" ]]; then
gcc_prefix="aarch64-linux-gnu-"
else
gcc_prefix=""
fi

if [[ $TARGET == *"windows"* ]]; then
extension=".exe"
else
extension=""
fi

mkdir "$tempdir/$package_name"

cp "target/$TARGET/release/$PROJECT_NAME$extension" "$tempdir/$package_name/"

if [[ $OS_NAME != "windows-latest" ]]; then
"${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME$extension"
fi

cp LICENSE "$tempdir/$package_name"

pushd "$tempdir"
if [[ $OS_NAME == "windows-latest" ]]; then
7z a "$out_dir/$package_name.zip" "$package_name"/*
else
tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*
fi
popd

rm -r "$tempdir"
}

pack

0 comments on commit 02c5177

Please sign in to comment.