Skip to content

Commit

Permalink
Build binaries for releases (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jun 6, 2022
1 parent da83987 commit b93da8f
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 2 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Release

on:
push:
tags:
- '*'

defaults:
run:
shell: bash

jobs:
all:
name: All

strategy:
fail-fast: false
matrix:
target:
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
include:
- target: x86_64-apple-darwin
os: macos-latest
target_rustflags: ''
- target: x86_64-pc-windows-msvc
os: windows-latest
target_rustflags: ''
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
target_rustflags: ''

runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v2

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

- name: Install Linux Dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install musl-tools libssl-dev pkg-config
- name: Release Type
id: release-type
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
echo ::set-output name=value::release
else
echo ::set-output name=value::prerelease
fi
- name: Package
id: package
env:
TARGET: ${{ matrix.target }}
REF: ${{ github.ref }}
OS: ${{ matrix.os }}
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
run: ./bin/package
shell: bash

- name: Publish Archive
uses: softprops/[email protected]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
draft: false
files: ${{ steps.package.outputs.archive }}
prerelease: ${{ steps.release-type.outputs.value == 'prerelease' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ord"
description = "Bitcoin satoshi ordinal number utility"
version = "0.0.1"
version = "0.0.2"
license = "CC0-1.0"
edition = "2021"
autotests = false
Expand Down
44 changes: 44 additions & 0 deletions bin/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

set -euxo pipefail

VERSION=${REF#"refs/tags/"}
DIST=`pwd`/dist

echo "Packaging ord $VERSION for $TARGET..."

test -f Cargo.lock || cargo generate-lockfile

echo "Building ord..."
RUSTFLAGS="--deny warnings $TARGET_RUSTFLAGS" \
cargo build --bin ord --target $TARGET --release
EXECUTABLE=target/$TARGET/release/ord

if [[ $OS == windows-latest ]]; then
EXECUTABLE=$EXECUTABLE.exe
fi

echo "Copying release files..."
mkdir dist
cp \
$EXECUTABLE \
Cargo.lock \
Cargo.toml \
LICENSE \
README.md \
$DIST

cd $DIST
echo "Creating release archive..."
case $OS in
ubuntu-latest | macos-latest)
ARCHIVE=$DIST/ord-$VERSION-$TARGET.tar.gz
tar czf $ARCHIVE *
echo "::set-output name=archive::$ARCHIVE"
;;
windows-latest)
ARCHIVE=$DIST/ord-$VERSION-$TARGET.zip
7z a $ARCHIVE *
echo "::set-output name=archive::`pwd -W`/ord-$VERSION-$TARGET.zip"
;;
esac
14 changes: 14 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ generate-paper-wallets:
print-paper-wallet path:
wkhtmltopdf -L 25mm -R 25mm -T 50mm -B 25mm {{path}} wallet.pdf
lp -o sides=two-sided-long-edge wallet.pdf

# publish current GitHub master branch
publish:
#!/usr/bin/env bash
set -euxo pipefail
rm -rf tmp/release
git clone [email protected]:casey/ord.git tmp/release
VERSION=`sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1`
cd tmp/release
git tag -a $VERSION -m "Release $VERSION"
git push origin $VERSION
cargo publish
cd ../..
rm -rf tmp/release

0 comments on commit b93da8f

Please sign in to comment.