diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..a30bdf14dc --- /dev/null +++ b/.github/workflows/release.yaml @@ -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/action-gh-release@v0.1.5 + 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 }} diff --git a/Cargo.lock b/Cargo.lock index 69917d70d4..be32d8af85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1553,7 +1553,7 @@ dependencies = [ [[package]] name = "ord" -version = "0.0.1" +version = "0.0.2" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index a75b6631c8..d29108bc53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/bin/package b/bin/package new file mode 100755 index 0000000000..842c89c376 --- /dev/null +++ b/bin/package @@ -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 diff --git a/justfile b/justfile index bc756e6c0b..ea47928598 100644 --- a/justfile +++ b/justfile @@ -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 git@github.com: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