Skip to content

Commit 69b8617

Browse files
Automatic release workflow
1 parent 63e33a6 commit 69b8617

File tree

8 files changed

+70
-38
lines changed

8 files changed

+70
-38
lines changed

.github/workflows/check-formatting.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Check formatting
33
on:
44
pull_request:
55
workflow_dispatch:
6+
workflow_call:
67
push:
78
branches:
89
- develop

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
packages: write
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414

1515
- name: Set up Docker Buildx
1616
uses: docker/setup-buildx-action@v3

.github/workflows/fork-test.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ name: Fork test
33
on:
44
pull_request:
55
workflow_dispatch:
6-
push:
7-
branches:
8-
- develop
9-
- main
6+
workflow_call:
107

118
jobs:
129
forktest:

.github/workflows/release.yml

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
name: Build runtimes & draft release
1+
name: Release new version
22

33
on:
44
workflow_dispatch:
5-
push:
6-
tags:
7-
- "v*.*.*"
85

96
jobs:
7+
check-formatting:
8+
uses: ./.github/workflows/check-formatting.yml
9+
fork-test:
10+
uses: ./.github/workflows/fork-test.yml
11+
test-contracts:
12+
uses: ./.github/workflows/test-contracts.yml
13+
test:
14+
uses: ./.github/workflows/test.yml
15+
try-runtime:
16+
uses: ./.github/workflows/try-runtime.yml
1017
build_binary:
1118
# use old ubuntu for GLIBC compatibility
1219
runs-on: ubuntu-20.04
1320
env:
1421
RUST_BACKTRACE: 1
1522
steps:
1623
- name: Checkout
17-
uses: actions/checkout@v2
24+
uses: actions/checkout@v4
1825

1926
- name: Install dependencies
2027
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
@@ -30,7 +37,7 @@ jobs:
3037
git restore-mtime
3138
3239
- name: Setup caching for rust/cargo
33-
uses: actions/cache@v2
40+
uses: actions/cache@v4
3441
with:
3542
path: |
3643
~/.cargo/bin/
@@ -55,7 +62,7 @@ jobs:
5562
build_runtimes:
5663
runs-on: ubuntu-latest
5764
steps:
58-
- uses: actions/checkout@v3
65+
- uses: actions/checkout@v4
5966

6067
- name: Srtool build mainnet runtime
6168
id: srtool_build
@@ -66,18 +73,22 @@ jobs:
6673
runtime_dir: ./substrate/bin/node/runtime
6774
tag: "1.74.0"
6875

76+
- name: Check version
77+
id: version
78+
run: echo "version=v$(cargo pkgid -p node-cli | cut -d'@' -f2)" >> "$GITHUB_OUTPUT"
79+
6980
- name: Mainnet Summary
7081
run: |
7182
echo '${{ steps.srtool_build.outputs.json }}' | jq . > liberland-srtool-digest.mainnet.json
7283
cat liberland-srtool-digest.mainnet.json
73-
cp "${{ steps.srtool_build.outputs.wasm_compressed }}" ./mainnet-${{github.ref_name}}.wasm
84+
cp "${{ steps.srtool_build.outputs.wasm_compressed }}" ./mainnet-${{ steps.version.outputs.version }}.wasm
7485
ls
7586
7687
- name: Upload mainnet runtime
7788
uses: actions/upload-artifact@v3
7889
with:
79-
name: mainnet-${{github.ref_name}}.wasm
80-
path: mainnet-${{github.ref_name}}.wasm
90+
name: mainnet-${{ steps.version.outputs.version }}.wasm
91+
path: mainnet-${{ steps.version.outputs.version }}.wasm
8192

8293
- name: Srtool build bastiat runtime
8394
id: srtool_build_bastiat
@@ -94,23 +105,33 @@ jobs:
94105
run: |
95106
echo '${{ steps.srtool_build_bastiat.outputs.json }}' | jq . > liberland-srtool-digest.bastiat.json
96107
cat liberland-srtool-digest.bastiat.json
97-
cp "${{ steps.srtool_build_bastiat.outputs.wasm_compressed }}" ./bastiat-${{github.ref_name}}.wasm
108+
cp "${{ steps.srtool_build_bastiat.outputs.wasm_compressed }}" ./bastiat-${{ steps.version.outputs.version }}.wasm
98109
ls
99110
100111
- name: Upload Bastiat runtime
101112
uses: actions/upload-artifact@v3
102113
with:
103-
name: bastiat-${{github.ref_name}}.wasm
104-
path: bastiat-${{github.ref_name}}.wasm
114+
name: bastiat-${{ steps.version.outputs.version }}.wasm
115+
path: bastiat-${{ steps.version.outputs.version }}.wasm
105116

106117
release:
107118
runs-on: ubuntu-latest
108-
if: startsWith(github.ref, 'refs/tags/v')
119+
permissions:
120+
contents: write
109121
needs:
110122
- build_runtimes
111123
- build_binary
124+
- check-formatting
125+
- fork-test
126+
- test-contracts
127+
- test
128+
- try-runtime
112129
steps:
113-
- uses: actions/checkout@v3
130+
- uses: actions/checkout@v4
131+
132+
- name: Check version
133+
id: version
134+
run: echo "version=v$(cargo pkgid -p node-cli | cut -d'@' -f2)" >> "$GITHUB_OUTPUT"
114135

115136
- name: Download binary
116137
uses: actions/download-artifact@v3
@@ -120,19 +141,20 @@ jobs:
120141
- name: Download Bastiat runtime
121142
uses: actions/download-artifact@v3
122143
with:
123-
name: bastiat-${{github.ref_name}}.wasm
144+
name: bastiat-${{ steps.version.outputs.version }}.wasm
124145

125146
- name: Download mainnet runtime
126147
uses: actions/download-artifact@v3
127148
with:
128-
name: mainnet-${{github.ref_name}}.wasm
149+
name: mainnet-${{ steps.version.outputs.version }}.wasm
129150

130151
- name: Release
131-
uses: softprops/action-gh-release@v1
152+
uses: softprops/action-gh-release@v2
132153
with:
133-
draft: true
134154
generate_release_notes: true
155+
tag_name: ${{ steps.version.outputs.version }}
156+
target_commitish: "${{ github.sha }}"
135157
files: |
136158
linux_x86_build
137-
mainnet-${{github.ref_name}}.wasm
138-
bastiat-${{github.ref_name}}.wasm
159+
mainnet-${{ steps.version.outputs.version }}.wasm
160+
bastiat-${{ steps.version.outputs.version }}.wasm

.github/workflows/test-contracts.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ name: Run contracts tests
33
on:
44
pull_request:
55
workflow_dispatch:
6-
push:
7-
branches:
8-
- develop
9-
- main
6+
workflow_call:
107

118
jobs:
129
test:

.github/workflows/test.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ name: Run tests
33
on:
44
pull_request:
55
workflow_dispatch:
6-
push:
7-
branches:
8-
- develop
9-
- main
6+
workflow_call:
107

118
jobs:
129
test:

.github/workflows/try-runtime.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ name: Try Runtime
33
on:
44
pull_request:
55
workflow_dispatch:
6-
push:
7-
branches:
8-
- develop
9-
- main
6+
workflow_call:
107

118
jobs:
129
tryruntime:

RELEASE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Releasing new version
2+
3+
## Sanity checks:
4+
5+
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.
6+
2. Check `version` in [runtime's Cargo.toml](./substrate/bin/node/runtime/Cargo.toml). Major version should match the `spec_version`.
7+
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.
8+
9+
## Release
10+
11+
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:
12+
* Run unit-tests
13+
* Run `try-runtime` migration checks (which detects things like state inconsitencies or pallet/state version mismatches)
14+
* Run fork test for both bastiat and mainnet and check if whole state is still parsable post-fork
15+
* Build runtimes in a reproducible way
16+
* Build new binary
17+
* Create a new GitHub Release
18+
* Build & publish new Docker Image
19+
2. Wait for the `Release new version` action to finish.
20+
3. Go to [GitHub Releases](https://github.com/liberland/liberland_substrate/releases). New release should be there, ready for deployment.
21+
4. (Optional) Open a new PR that bumps versions for the next release. [Sample PR](https://github.com/liberland/liberland_substrate/pull/404/files).

0 commit comments

Comments
 (0)