Skip to content

Commit

Permalink
Build release artifacts for git tags
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Oct 13, 2023
1 parent 3388e14 commit 58ca770
Showing 1 changed file with 222 additions and 0 deletions.
222 changes: 222 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
---
name: Build Release Artifacts

on:
push:
tags:
- "*"

permissions: read-all

jobs:
sanity-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Sanity check tag name
run: |
git describe --tag | grep -E "mainnet|testnet"
build-native-runtime:
needs: sanity-check
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-22.04, windows-2022, macos-11]
runs-on: ${{ matrix.operating-system }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install protobuf
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure rustc version
shell: bash
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: wasm32-unknown-unknown
profile: minimal
override: true

- name: Install MacOS aarch64 target
if: matrix.operating-system == 'macos-11'
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUSTC_VERSION }}
target: aarch64-apple-darwin
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2

- name: Figure out platform
shell: bash
run: |
PLATFORM=$(rustup target list --installed | grep "$(uname -m)")
echo "PLATFORM=$PLATFORM" >> "$GITHUB_ENV"
- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: DEBUG
shell: bash
run: |
echo "Tag & Platform is '${{ env.TAG_NAME }}-${{ env.PLATFORM }}'"
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release

- name: Build MacOS aarch64 target
if: matrix.operating-system == 'macos-11'
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target aarch64-apple-darwin

- name: Compress
uses: thedoctor0/[email protected]
with:
type: "zip"
directory: "target/release/"
path: "frontier-template-node*"
filename: "../../creditcoin-${{ env.TAG_NAME }}-${{ env.PLATFORM }}.zip"
exclusions: "frontier-template-node.d"

- name: Compress MacOS aarch64 target
if: matrix.operating-system == 'macos-11'
uses: thedoctor0/[email protected]
with:
type: "zip"
directory: "target/aarch64-apple-darwin/release/"
path: "frontier-template-node*"
filename: "../../../creditcoin-${{ env.TAG_NAME }}-aarch64-apple-darwin.zip"
exclusions: "frontier-template-node.d"

- name: Upload binary
uses: actions/upload-artifact@v3
with:
path: "creditcoin-${{ env.TAG_NAME }}-*.zip"
if-no-files-found: error

build-wasm-runtime:
needs: sanity-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: Build WASM runtime
id: srtool_build
uses: chevdor/[email protected]
with:
chain: "creditcoin"
runtime_dir: runtime
package: frontier-template-runtime
tag: "1.70.0"
workdir: ${{ github.workspace }}

- name: DEBUG
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > creditcoin-srtool-digest.json
cat creditcoin-srtool-digest.json
echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}"
- name: Rename file
run: |
mv ${{ steps.srtool_build.outputs.wasm }} creditcoin-${{ env.TAG_NAME }}-runtime.wasm
- name: Upload binary
uses: actions/upload-artifact@v3
with:
path: "*.wasm"
if-no-files-found: error

docker-build:
needs: sanity-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: Build docker image
run: |
docker build -t gluwa/creditcoin-next:${{ env.TAG_NAME }} .
# echo "${{ secrets.DOCKER_PUSH_PASSWORD }}" | docker login -u="${{ secrets.DOCKER_PUSH_USERNAME }}" --password-stdin
# docker push gluwa/creditcoin-next:${{ env.TAG_NAME }}
# only -mainnet images are tagged as :latest
# shellcheck disable=SC2046,SC2143
if [ $(echo "${{ env.TAG_NAME}}" | grep "mainnet") ]; then
docker tag gluwa/creditcoin-next:${{ env.TAG_NAME }} gluwa/creditcoin-next:latest
# docker push gluwa/creditcoin-next:latest
fi
docker logout
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- build-native-runtime
- build-wasm-runtime
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Figure out tag name
shell: bash
run: |
TAG_NAME=$(git describe --tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV"
- name: Download binaries
uses: actions/download-artifact@v3

- name: DEBUG
shell: bash
run: |
ls -lR
- name: Make the release
uses: softprops/action-gh-release@v1
with:
files: "artifact/creditcoin-*${{ env.TAG_NAME }}*"
fail_on_unmatched_files: true
name: ${{ env.TAG_NAME }}

0 comments on commit 58ca770

Please sign in to comment.