Skip to content

Commit

Permalink
Merge pull request #144 from symmetree-labs/homebrew-release
Browse files Browse the repository at this point in the history
Build Homebrew compatible binaries
  • Loading branch information
rsdy committed Jun 1, 2022
2 parents 41b14fa + b6cea59 commit 6505437
Showing 1 changed file with 40 additions and 7 deletions.
47 changes: 40 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
release:
types: [ published ]

env:
version: ${{ github.event.release.tag_name || github.head_ref }}

jobs:
security_audit:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -36,30 +39,37 @@ jobs:
name: [
linux,
macos,
macos-m1,
windows
]

include:
- name: linux
os: ubuntu-latest
asset_name: 0s-linux-x86_64-static
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-linux-x86_64
target: x86_64-unknown-linux-musl
cross: true

- name: macos
os: macos-latest
asset_name: 0s-macos-x86_64
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-macos-x86_64
target: x86_64-apple-darwin
cross: false

- name: macos-m1
os: macos-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-macos-aarch64
target: aarch64-apple-darwin
cross: true

- name: windows
os: windows-latest
asset_name: 0s-windows-x86_64.exe
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-windows-x86_64.exe
target: x86_64-pc-windows-msvc
cross: false

rust:
- 1.60.0 # MSRV
- 1.61.0 # MSRV

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -72,6 +82,7 @@ jobs:
target: ${{ matrix.target }}

- name: Test
if: matrix.target != 'aarch64-apple-darwin'
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
Expand Down Expand Up @@ -107,6 +118,19 @@ jobs:
uses: actions/download-artifact@v3
with:
path: bin

- name: Package artifacts
run: |
set -e
cd bin
for dir in 0s-*-linux-* 0s-*-macos-*; do
(cd $dir;
echo $dir
tar czf $dir.tar.gz 0s;
sha256sum $dir.tar.gz
)
done
- name: Attach binaries to release
uses: actions/github-script@v6
with:
Expand All @@ -120,15 +144,24 @@ jobs:
const artifacts = await fs.readdir('bin/');
for (dir of artifacts) {
console.log(`Uploading ${dir}/0s for release ${release_id}`);
const files = await fs.readdir(`bin/${dir}`);
for (file of files) {
if (file === '0s') {
continue;
}
var file_name = file;
if (file === '0s.exe') {
file_name = `${dir}.exe`;
}
console.log(`Uploading ${dir}/${file} as ${file_name} for release ${release_id}`);
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id,
name: path.basename(dir),
name: file_name,
data: await fs.readFile(`bin/${dir}/${file}`),
});
Expand Down

0 comments on commit 6505437

Please sign in to comment.