thor-devkit 0.1.0

Rust library to aid coding with VeChain: wallets, transactions signing, encoding and verification, smart contract ABI interfacing, etc.
Documentation
name: Release

on:
  push:
    tags: [v*]

permissions:
  contents: read

jobs:
  release-github:
    name: Publish to GitHub releases
    runs-on: ubuntu-latest
    permissions:
      contents: write
    if: startsWith(github.ref, 'refs/tags/')
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1
          persist-credentials: false
      - name: Set variables
        id: vars
        run: |
          CHANGELOG=$(awk '/^## v/ {n=NR; i++}; i==1 {if (NR==n) {print "## Release Notes"} else {print}}; i>1 {exit}' CHANGELOG.md \
            | python3 -c 'import sys, json; print(json.dumps(sys.stdin.read()))')
          echo "changelog=$CHANGELOG" >> "$GITHUB_OUTPUT"

      - name: Create GitHub release
        uses: softprops/action-gh-release@v2
        with:
          prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
          generate_release_notes: true
          body: ${{ fromJson(steps.vars.outputs.changelog) }}

  release-crate:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1
          persist-credentials: false
      - name: Publish crate to crates.io
        run: |
          name=$(cargo metadata -q --no-deps | jq -r '.packages[0].name')
          version=$(cargo metadata -q --no-deps | jq -r '.packages[0].version')
          echo "Publishing ${name}-${version}"
          cargo publish --token ${{ secrets.CARGO_TOKEN }}