Skip to content

Commit

Permalink
Build snapcake binary (#78)
Browse files Browse the repository at this point in the history
* Update polkadot-sdk

* Add snapcake.Dockerfile

* Build snapcake in release workflow

* Nit

* No sha tag

* Fix switching to blocks first sync

* Add --sync-target to stop at a certain height

* Fix test
  • Loading branch information
liuchengxu authored Nov 27, 2024
1 parent 46f2675 commit e9b1722
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 178 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ jobs:
packages: write
strategy:
matrix:
platform:
build:
- arch: linux/amd64
profile: production
image: subcoin # Subcoin Node
suffix: ubuntu-x86_64-${{ github.ref_name }}
image-suffix: ''
- arch: linux/amd64
image: snapcake
suffix: ubuntu-x86_64-${{ github.ref_name }}
image-suffix: ''
dockerfile-suffix: ''
# TODO: https://github.com/subcoin-project/subcoin/issues/13
# - arch: linux/arm64
# profile: production
# suffix: ubuntu-aarch64-${{ github.ref_name }}
# image-suffix: '-aarch64'
# dockerfile-suffix: '.aarch64'
Expand Down Expand Up @@ -58,21 +60,21 @@ jobs:
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/subcoin-project/subcoin
ghcr.io/subcoin-project/${{ matrix.build.image }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
# type=sha
flavor: |
latest=false
suffix=${{ matrix.platform.image-suffix }}
suffix=${{ matrix.build.image-suffix }}
- name: Build and push image
id: build
uses: docker/build-push-action@v6
with:
file: Dockerfile${{ matrix.platform.dockerfile-suffix }}
platforms: ${{ matrix.platform.arch }}
file: docker/${{ matrix.build.image }}.Dockerfile
platforms: ${{ matrix.build.arch }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
push: ${{ github.event_name != 'pull_request' }}
Expand All @@ -83,7 +85,6 @@ jobs:
provenance: false
build-args: |
SUBSTRATE_CLI_GIT_COMMIT_HASH=${{ github.sha }}
PROFILE=${{ matrix.platform.profile }}
- name: Image digest
run: echo ${{ steps.build.outputs.digest }}
26 changes: 17 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,26 @@ jobs:
- os: ubuntu-latest
os_prefix: ubuntu
target: aarch64-unknown-linux-gnu
artifact_name: subcoin
command: cross

- os: ubuntu-latest
os_prefix: ubuntu
target: x86_64-unknown-linux-gnu
artifact_name: subcoin
command: cargo

- os: macos-latest
os_prefix: macos
target: x86_64-apple-darwin
artifact_name: subcoin
command: cargo

- os: macos-14
os_prefix: macos
target: aarch64-apple-darwin
artifact_name: subcoin
command: cargo

- os: windows-latest
os_prefix: windows
target: x86_64-pc-windows-msvc
artifact_name: subcoin.exe
command: cargo

steps:
Expand Down Expand Up @@ -88,10 +83,14 @@ jobs:
target/
key: ${{ runner.os }}-${{ matrix.build.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build binary
- name: Build subcoin binary
run: |
${{ matrix.build.command }} build --profile production --bin subcoin --locked --target ${{ matrix.build.target }}
- name: Build snapcake binary
run: |
${{ matrix.build.command }} build --profile production --package subcoin-snapcake --locked --target ${{ matrix.build.target }}
- name: Get version without v prefix (Ubuntu/macOS)
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
if: ${{ matrix.build.os != 'windows-latest' }}
Expand All @@ -102,11 +101,20 @@ jobs:
echo "VERSION=$version" >> $env:GITHUB_ENV
if: ${{ matrix.build.os == 'windows-latest' }}

- name: Upload binaries to release
- name: Upload subcoin binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.build.target }}/production/subcoin${{ matrix.build.os == 'windows-latest' && '.exe' || '' }}
tag: ${{ github.ref }}
asset_name: subcoin-${{ env.VERSION }}-${{ matrix.build.target }}${{ matrix.build.os == 'windows-latest' && '.exe' || '' }}
prerelease: true

- name: Upload snapcake binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.build.target }}/production/${{ matrix.build.artifact_name }}
file: target/${{ matrix.build.target }}/production/snapcake${{ matrix.build.os == 'windows-latest' && '.exe' || '' }}
tag: ${{ github.ref }}
asset_name: ${{ matrix.build.artifact_name }}-${{ env.VERSION }}-${{ matrix.build.target }}
asset_name: snapcake-${{ env.VERSION }}-${{ matrix.build.target }}${{ matrix.build.os == 'windows-latest' && '.exe' || '' }}
prerelease: true
Loading

0 comments on commit e9b1722

Please sign in to comment.