Skip to content

Commit

Permalink
CLI Release Process (#532)
Browse files Browse the repository at this point in the history
* Run workflow

* Rename

* Add dependency

* Use target os

* Fix yaml

* Fix typo

* Don't use cross on macos

* Skip cross

* Add openssl to windows

* Skip windows for now

* Skip windows upload

* Properly skip windows

* Skip all windows

* Fix cli path

* Use predictable name for artifact

* Simplify artifact naming

* Use warpbuilds

* Fix caching

* Fix artifacts path

* Remove run step

* Use musl

* Add musl tools

* Add seed phrase support

* Only release on main

* Lint

* Derive default

* Release

* Remove CLI release branch

* Fix order of arguments

* Fix failing test

* Add group info command
  • Loading branch information
neekolas authored Feb 23, 2024
1 parent 334ee4b commit fe51613
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 86 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Release CLI
on:
push:
branches:
- main
jobs:
build:
strategy:
fail-fast: true
matrix:
build:
- linux-x86_64
# Windows is erroring right now
# - windows-x86_64-gnu
- macos-aarch64
include:
- build: linux-x86_64
os: warp-ubuntu-latest-x64-16x
target: x86_64-unknown-linux-musl
- build: macos-aarch64
os: warp-macos-13-arm64-6x
target: aarch64-apple-darwin
# - build: windows-x86_64-gnu
# os: windows-latest
# target: x86_64-pc-windows-gnu
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v1

- name: "Cache"
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
./examples/cli/target/${{ matrix.target }}
key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}

- run: sudo apt install musl-tools
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}

- name: Install openssl windows
if: ${{ matrix.build == 'windows-x86_64-gnu' }}
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install openssl

- name: Build target
uses: actions-rs/cargo@v1
if:
with:
use-cross: false
command: build
args: --release --target ${{ matrix.target }} --manifest-path examples/cli/Cargo.toml --target-dir examples/cli/target

- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.build }}
path: examples/cli/target/${{ matrix.target }}/release/xmtp_cli*
retention-days: 1

release:
needs: ["build"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts

- name: Get short SHA
id: slug
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: cli-${{ steps.slug.outputs.sha7 }}
release_name: cli-${{ steps.slug.outputs.sha7 }}
body: "Release of cli for commit ${{ github.sha}}"
draft: false
prerelease: true

# - name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./examples/cli/target/x86_64-pc-windows-gnu.exe
# asset_name: cli-x86_64-pc-windows-gnu.exe
# asset_content_type: application/octet-stream

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/macos-aarch64/xmtp_cli
asset_name: cli-macos-aarch64
asset_content_type: application/octet-stream

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/linux-x86_64/xmtp_cli
asset_name: cli-linux-x86_64
asset_content_type: application/octet-stream
20 changes: 19 additions & 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 examples/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ path = "cli-client.rs"

[dependencies]
clap = { version = "4.4.6", features = ["derive"] }
env_logger = "0.10.0"
ethers = "2.0.4"
ethers-core = "2.0.4"
femme = "2.2.1"
futures = "0.3.28"
hex = "0.4.3"
kv-log-macro = "1.0.7"
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Use the CLI to send a [double ratchet message](https://github.com/xmtp/libxmtp/b
6. Add user 2 to the group

```bash
./xli.sh --db user1.db3 add-group-member $GROUP_ID $USER_2_ACCOUNT_ADDRESS
./xli.sh --db user1.db3 add-group-members $GROUP_ID --account-addresses $USER_2_ACCOUNT_ADDRESS
```

7. Send a message
Expand Down
Loading

0 comments on commit fe51613

Please sign in to comment.