Skip to content

Commit

Permalink
Crates.io publishing (#52)
Browse files Browse the repository at this point in the history
* crates.io workflow
  • Loading branch information
Voxelot authored Dec 24, 2021
1 parent 6fc4ae5 commit ece141a
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Compile and Test
name: CI

on:
push:
branches:
- master
tags:
- v*
pull_request:
release:
types: [published]

env:
CARGO_TERM_COLOR: always
Expand All @@ -20,12 +20,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup SSH agent
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: |
${{ secrets.PRIVATE_KEY_FUEL_STORAGE }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -59,3 +53,29 @@ jobs:
with:
command: test
args: --verbose --package fuel-merkle-test-helpers

publish:
# Only do this job if publishing a release
needs: build
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Verify tag version
run: |
cargo install toml-cli
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
- name: Publish crate
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
35 changes: 35 additions & 0 deletions fuel-merkle/.github/workflows/scripts/verify_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e

err() {
echo -e "\e[31m\e[1merror:\e[0m $@" 1>&2;
}

status() {
WIDTH=12
printf "\e[32m\e[1m%${WIDTH}s\e[0m %s\n" "$1" "$2"
}

REF=$1
MANIFEST=$2

if [ -z "$REF" ]; then
err "Expected ref to be set"
exit 1
fi

if [ -z "$MANIFEST" ]; then
err "Expected manifest to be set"
exit 1
fi

# strip preceeding 'v' if it exists on tag
REF=${REF/#v}
TOML_VERSION=$(toml get $MANIFEST package.version | tr -d '"')

if [ "$TOML_VERSION" != "$REF" ]; then
err "Crate version $TOML_VERSION, doesn't match tag version $REF"
exit 1
else
status "Crate version matches tag $TOML_VERSION"
fi
2 changes: 1 addition & 1 deletion fuel-merkle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description = "Fuel Merkle tree libraries."
[dependencies]
bytes = "~1.1"
digest = "~0.9.0"
fuel-storage = { git = "ssh://git@github.com/FuelLabs/fuel-storage.git" }
fuel-storage = { version = "0.1" }
generic-array = "~0.14.4"
hex = "~0.4.3"
lazy_static = "~1.4.0"
Expand Down
6 changes: 6 additions & 0 deletions fuel-merkle/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# fuel-merkle

[![build](https://github.com/FuelLabs/fuel-merkle/actions/workflows/ci.yml/badge.svg)](https://github.com/FuelLabs/fuel-merkle/actions/workflows/ci.yml)
[![crates.io](https://img.shields.io/crates/v/fuel-merkle?label=latest)](https://crates.io/crates/fuel-merkle)
[![docs](https://docs.rs/fuel-merkle/badge.svg)](https://docs.rs/fuel-merkle/)
[![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe)

Fuel Merkle trees

0 comments on commit ece141a

Please sign in to comment.