-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a release flow that let's us build releases and then deploy them separately. Since deploys are deterministic, this "release first, deploy later" flow should be quite appealing. e.g. it means you can always redeploy older releases to new chains, etc.
- Loading branch information
Showing
5 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Prepare Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge build | ||
- name: Prepare Release | ||
run: | | ||
script/prepare-release.sh | ||
env: | ||
CODE_JAR: ${{ vars.CODE_JAR }} | ||
RPC_URL: ${{ vars.SEPOLIA_RPC_URL }} | ||
|
||
- uses: ncipollo/release-action@v1 | ||
with: | ||
ref: "${{ github.sha }}" | ||
artifacts: "release/Sleuth.json,release/Sleuth.sol,release/sleuth@*" | ||
bodyFile: "release/RELEASE.md" | ||
allowUpdates: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
name: test | ||
|
||
on: workflow_dispatch | ||
on: | ||
push: | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
release/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
pragma solidity ^0.8.23; | ||
|
||
import "forge-std/Script.sol"; | ||
import "../src/Sleuth.sol"; | ||
|
||
contract SleuthScript is Script { | ||
interface CodeJar { | ||
function saveCode(bytes memory code) external returns (address); | ||
} | ||
|
||
contract Prepare is Script { | ||
function setUp() public {} | ||
|
||
function run() public { | ||
vm.broadcast(); | ||
function run() public returns (address) { | ||
CodeJar codeJar = CodeJar(vm.envAddress("CODE_JAR")); | ||
console.log("Code Jar Address:", address(codeJar)); | ||
console.log("Chain ID:", block.chainid); | ||
console.logBytes(address(codeJar).code); | ||
|
||
address sleuthAddress = codeJar.saveCode(type(Sleuth).creationCode); | ||
|
||
console.log("Sleuth Address:", sleuthAddress); | ||
|
||
return sleuthAddress; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
if [ -z "$CODE_JAR" ]; then | ||
echo "Missing CODE_JAR env var" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$RPC_URL" ]; then | ||
echo "Missing RPC_URL env var" | ||
exit 1 | ||
fi | ||
|
||
if ! command -v jq &> /dev/null; then | ||
echo "jq could not be found" | ||
exit 1 | ||
fi | ||
|
||
forge build | ||
mkdir -p release/ | ||
cp out/Sleuth.sol/Sleuth.json release/ | ||
cp src/Sleuth.sol release/ | ||
title="$(git log -1 --pretty="%s")" | ||
body="$(git log -1 --pretty="%b")" | ||
|
||
if [ -z "$title" ]; then | ||
echo "must include git commit title" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$body" ]; then | ||
echo "must include git commit body" | ||
exit 1 | ||
fi | ||
|
||
sleuth_address="$(forge script --rpc-url="$RPC_URL" --json --silent script/Sleuth.s.sol:Prepare | tee | jq -r '.returns."0".value')" | ||
|
||
echo "title=$title" | ||
echo "body=$body" | ||
echo "sleuth_address=$sleuth_address" | ||
|
||
echo "$sleuth_address" > "release/sleuth@$sleuth_address" | ||
|
||
cat > release/RELEASE.md <<EOF | ||
## $title | ||
Sleuth Address: $sleuth_address | ||
$body | ||
EOF |