Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete release workflow #397

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Check formatting
on:
pull_request:
workflow_dispatch:
workflow_call:
push:
branches:
- develop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/fork-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ name: Fork test
on:
pull_request:
workflow_dispatch:
push:
branches:
- develop
- main
workflow_call:

jobs:
forktest:
Expand Down
64 changes: 43 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
name: Build runtimes & draft release
name: Release new version

on:
workflow_dispatch:
push:
tags:
- "v*.*.*"

jobs:
check-formatting:
uses: ./.github/workflows/check-formatting.yml
fork-test:
uses: ./.github/workflows/fork-test.yml
test-contracts:
uses: ./.github/workflows/test-contracts.yml
test:
uses: ./.github/workflows/test.yml
try-runtime:
uses: ./.github/workflows/try-runtime.yml
build_binary:
# use old ubuntu for GLIBC compatibility
runs-on: ubuntu-20.04
env:
RUST_BACKTRACE: 1
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential git clang curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config git-restore-mtime
Expand All @@ -30,7 +37,7 @@ jobs:
git restore-mtime

- name: Setup caching for rust/cargo
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand All @@ -55,7 +62,7 @@ jobs:
build_runtimes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Srtool build mainnet runtime
id: srtool_build
Expand All @@ -66,18 +73,22 @@ jobs:
runtime_dir: ./substrate/bin/node/runtime
tag: "1.74.0"

- name: Check version
id: version
run: echo "version=v$(cargo pkgid -p node-cli | cut -d'@' -f2)" >> "$GITHUB_OUTPUT"

- name: Mainnet Summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > liberland-srtool-digest.mainnet.json
cat liberland-srtool-digest.mainnet.json
cp "${{ steps.srtool_build.outputs.wasm_compressed }}" ./mainnet-${{github.ref_name}}.wasm
cp "${{ steps.srtool_build.outputs.wasm_compressed }}" ./mainnet-${{ steps.version.outputs.version }}.wasm
ls

- name: Upload mainnet runtime
uses: actions/upload-artifact@v3
with:
name: mainnet-${{github.ref_name}}.wasm
path: mainnet-${{github.ref_name}}.wasm
name: mainnet-${{ steps.version.outputs.version }}.wasm
path: mainnet-${{ steps.version.outputs.version }}.wasm

- name: Srtool build bastiat runtime
id: srtool_build_bastiat
Expand All @@ -94,23 +105,33 @@ jobs:
run: |
echo '${{ steps.srtool_build_bastiat.outputs.json }}' | jq . > liberland-srtool-digest.bastiat.json
cat liberland-srtool-digest.bastiat.json
cp "${{ steps.srtool_build_bastiat.outputs.wasm_compressed }}" ./bastiat-${{github.ref_name}}.wasm
cp "${{ steps.srtool_build_bastiat.outputs.wasm_compressed }}" ./bastiat-${{ steps.version.outputs.version }}.wasm
ls

- name: Upload Bastiat runtime
uses: actions/upload-artifact@v3
with:
name: bastiat-${{github.ref_name}}.wasm
path: bastiat-${{github.ref_name}}.wasm
name: bastiat-${{ steps.version.outputs.version }}.wasm
path: bastiat-${{ steps.version.outputs.version }}.wasm

release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
needs:
- build_runtimes
- build_binary
- check-formatting
- fork-test
- test-contracts
- test
- try-runtime
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check version
id: version
run: echo "version=v$(cargo pkgid -p node-cli | cut -d'@' -f2)" >> "$GITHUB_OUTPUT"

- name: Download binary
uses: actions/download-artifact@v3
Expand All @@ -120,19 +141,20 @@ jobs:
- name: Download Bastiat runtime
uses: actions/download-artifact@v3
with:
name: bastiat-${{github.ref_name}}.wasm
name: bastiat-${{ steps.version.outputs.version }}.wasm

- name: Download mainnet runtime
uses: actions/download-artifact@v3
with:
name: mainnet-${{github.ref_name}}.wasm
name: mainnet-${{ steps.version.outputs.version }}.wasm

- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
tag_name: ${{ steps.version.outputs.version }}
target_commitish: "${{ github.sha }}"
files: |
linux_x86_build
mainnet-${{github.ref_name}}.wasm
bastiat-${{github.ref_name}}.wasm
mainnet-${{ steps.version.outputs.version }}.wasm
bastiat-${{ steps.version.outputs.version }}.wasm
5 changes: 1 addition & 4 deletions .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ name: Run contracts tests
on:
pull_request:
workflow_dispatch:
push:
branches:
- develop
- main
workflow_call:

jobs:
test:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ name: Run tests
on:
pull_request:
workflow_dispatch:
push:
branches:
- develop
- main
workflow_call:

jobs:
test:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/try-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ name: Try Runtime
on:
pull_request:
workflow_dispatch:
push:
branches:
- develop
- main
workflow_call:

jobs:
tryruntime:
Expand Down
21 changes: 21 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Releasing new version

## Sanity checks:

1. Check `spec_version` value in [runtime's lib.rs](./substrate/bin/node/runtime/src/lib.rs). There are 2: one for mainnet and one for testnet. They should be the same and higher than the last release.
2. Check `version` in [runtime's Cargo.toml](./substrate/bin/node/runtime/Cargo.toml). Major version should match the `spec_version`.
3. Check `version` in [cli's Cargo.toml](./substrate/bin/node/cli/Cargo.toml). Major version should match the `spec_version`. This is the version that will be used as the name of the release and tag.

## Release

1. Go to the [Release new version](https://github.com/liberland/liberland_substrate/actions/workflows/release.yml) action in GitHub, select `Run workflow`, choose the branch (usually `develop` or `main`) and run it. This action will do the following:
* Run unit-tests
* Run `try-runtime` migration checks (which detects things like state inconsitencies or pallet/state version mismatches)
* Run fork test for both bastiat and mainnet and check if whole state is still parsable post-fork
* Build runtimes in a reproducible way
* Build new binary
* Create a new GitHub Release
* Build & publish new Docker Image
2. Wait for the `Release new version` action to finish.
3. Go to [GitHub Releases](https://github.com/liberland/liberland_substrate/releases). New release should be there, ready for deployment.
4. (Optional) Open a new PR that bumps versions for the next release. [Sample PR](https://github.com/liberland/liberland_substrate/pull/404/files).
2 changes: 1 addition & 1 deletion substrate/scripts/fork-test/mainnet.config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ BUILDDIR="$(realpath "$(dirname "$0")/../../..")/target/release"
BINARY="$BUILDDIR/substrate-node"
RUNTIME="${RUNTIME:-$BUILDDIR/wbuild/kitchensink-runtime/kitchensink_runtime.compact.compressed.wasm}"
ORIG_CHAIN="mainnet"
WS_ENDPOINT="wss://mainnet.liberland.org"
WS_ENDPOINT="wss://liberland-rpc.dwellir.com"
Loading