chore(deps): bump github-action packages #346
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
name: Docker | |
on: | |
# TODO: build nightly image | |
# schedule: | |
# - cron: '22 3 * * *' | |
push: | |
branches: [ main, 'v0.11*', '0.11*' ] | |
# Publish semver tags as releases. | |
tags: [ 'v*.*.*', '0.11.*', '1.*' ] | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ${{ github.ref_type != 'tag' && 'ghcr.io/' || '' }} | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: godwoken-prebuilds | |
jobs: | |
docker-build-push: | |
# Same as image base | |
runs-on: ubuntu-20.04 | |
# Map the meta step outputs to this job outputs | |
outputs: | |
image_name: ${{ steps.result.outputs.image_name }} | |
image_tag: ${{ steps.result.outputs.image_tag }} | |
# If you specify the access for any of these scopes, all of those that are not specified are set to none. | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os }}-cargo-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Install Rust components | |
run: rustup component add rustfmt && rustup component add clippy | |
- name: Install moleculec | |
run: | | |
test "$(moleculec --version)" = "Moleculec 0.7.2" \ | |
|| cargo install moleculec --version 0.7.2 --force | |
- name: Install capsule | |
env: | |
CAPSULE_VERSION: v0.7.0 | |
run: | | |
(which capsule && test "$(capsule --version)" = "Capsule 0.7.0") \ | |
|| curl -OL https://github.com/nervosnetwork/capsule/releases/download/${CAPSULE_VERSION}/capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ | |
&& tar xf capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ | |
&& mv capsule_${CAPSULE_VERSION}_x86_64-linux/capsule ~/.cargo/bin/ | |
capsule --version | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
# GitHub automatically creates a unique GITHUB_TOKEN secret to use in this workflow. | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.ref_type != 'tag' && github.repository_owner || secrets.DOCKERHUB_USERNAME }} | |
password: ${{ github.ref_type != 'tag' && secrets.GITHUB_TOKEN || secrets.DOCKERHUB_TOKEN }} | |
- name: Prepare components | |
id: prepare | |
run: | | |
make prepare-repos | |
echo "Record the component's reference to the outputs of this step" | |
cat versions | |
- name: Print the references of components | |
run: | | |
echo ref.component.godwoken=${{ steps.prepare.outputs.GODWOKEN_REF }} | |
echo ref.component.godwoken-scripts=${{ steps.prepare.outputs.GODWOKEN_SCRIPTS_REF }} | |
echo ref.component.godwoken-polyjuice=${{ steps.prepare.outputs.POLYJUICE_REF }} | |
echo ref.component.clerkb=${{ steps.prepare.outputs.CLERKB_REF }} | |
- name: Cache of component.clerkb | |
id: clerkb-cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
build/clerkb/build/debug/poa | |
build/clerkb/build/debug/state | |
key: component.clerkb-${{ steps.prepare.outputs.clerkb-sha1 }} | |
- name: Build clerkb | |
if: steps.clerkb-cache.outputs.cache-hit != 'true' | |
working-directory: build/clerkb | |
run: yarn && make all-via-docker | |
# Skip building godwoken-scripts because Godwoken v0 is in maintenance mode with no change. | |
# - name: Cache of component.godwoken-scripts | |
# id: godwoken-scripts-cache | |
# uses: actions/cache@v3 | |
# with: | |
# path: | | |
# build/godwoken-scripts/build/release/* | |
# build/godwoken-scripts/c/build/*-generator | |
# build/godwoken-scripts/c/build/*-validator | |
# build/godwoken-scripts/c/build/account_locks/* | |
# key: component.godwoken-scripts-${{ steps.prepare.outputs.godwoken-scripts-sha1 }} | |
# - name: Build godwoken-scripts | |
# if: steps.godwoken-scripts-cache.outputs.cache-hit != 'true' | |
# working-directory: build/godwoken-scripts | |
# run: cd c && make && cd .. && capsule build --release --debug-output | |
# Skip building godwoken-polyjuice because Godwoken v0 is in maintenance mode with no change. | |
# - name: Cache of component.godwoken-polyjuice | |
# id: godwoken-polyjuice-cache | |
# uses: actions/cache@v3 | |
# with: | |
# path: | | |
# build/godwoken-polyjuice/build/*generator* | |
# build/godwoken-polyjuice/build/*validator* | |
# key: component.godwoken-polyjuice-${{ steps.prepare.outputs.godwoken-polyjuice-sha1 }} | |
# - name: Build godwoken-polyjuice | |
# if: steps.godwoken-polyjuice-cache.outputs.cache-hit != 'true' | |
# working-directory: build/godwoken-polyjuice | |
# run: make all-via-docker | |
- name: Cache of component.godwoken | |
id: godwoken-cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
build/godwoken/target/release/godwoken | |
build/godwoken/target/release/gw-tools | |
key: component.godwoken-${{ steps.prepare.outputs.godwoken-sha1 }} | |
- name: Cache Godwoken target directory | |
if: steps.godwoken-cache.outputs.cache-hit != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
build/godwoken/target | |
key: ${{ runner.os }}-cargo-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Build godwoken | |
if: steps.godwoken-cache.outputs.cache-hit != 'true' | |
working-directory: build/godwoken | |
env: | |
# For ckb-rocksdb. | |
PORTABLE: true | |
CARGO_PROFILE_RELEASE_LTO: thin | |
run: rustup component add rustfmt && cargo build --release | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}${{ startsWith(github.ref, 'refs/tags') && github.repository_owner == 'nervosnetwork' && 'nervos' || github.repository_owner }}/${{ env.IMAGE_NAME }} | |
# dynamically set date as a suffix | |
tags: | | |
type=ref,event=tag | |
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmm'}} | |
type=ref,event=branch | |
labels: | | |
maintainer=Nervos Core Dev <[email protected]> | |
org.opencontainers.image.authors=Nervos Core Dev <[email protected]> | |
source.component.godwoken=https://github.com/nervosnetwork/godwoken | |
source.component.godwoken-scripts-Scripts=https://github.com/nervosnetwork/godwoken-scripts | |
source.component.godwoken-polyjuice=https://github.com/nervosnetwork/godwoken-polyjuice | |
source.component.clerkb=https://github.com/nervosnetwork/clerkb.git | |
ref.component.godwoken=${{ steps.prepare.outputs.GODWOKEN_REF }} | |
ref.component.godwoken-sha1=${{ steps.prepare.outputs.godwoken-sha1 }} | |
ref.component.godwoken-scripts=${{ steps.prepare.outputs.GODWOKEN_SCRIPTS_REF }} | |
ref.component.godwoken-scripts-sha1=${{ steps.prepare.outputs.godwoken-scripts-sha1 }} | |
ref.component.godwoken-polyjuice=${{ steps.prepare.outputs.POLYJUICE_REF }} | |
ref.component.godwoken-polyjuice-sha1=${{ steps.prepare.outputs.godwoken-polyjuice-sha1 }} | |
ref.component.clerkb=${{ steps.prepare.outputs.OMNI_LOCK_REF }} | |
ref.component.clerkb-sha1=${{ steps.prepare.outputs.clerkb-sha1 }} | |
# Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push Docker image to ${{ env.REGISTRY }}${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
if: ${{ github.ref_type != 'tag' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile.fast | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# Build and push Docker image with Buildx (don't push on PR) | |
# only for new tag | |
- name: Build and push Docker image to https://hub.docker.com/r/nervos/godwoken-prebuilds | |
if: ${{ github.repository_owner == 'nervosnetwork' && startsWith(github.ref, 'refs/tags') }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile.fast | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Check versions of the binaries in ${{ fromJSON(steps.meta.outputs.json).tags[0] }} | |
if: ${{ github.event_name != 'pull_request' }} | |
env: | |
IMAGE: ${{ fromJSON(steps.meta.outputs.json).tags[0] }} | |
run: | | |
docker run --rm ${{ env.IMAGE }} godwoken --version | |
docker run --rm ${{ env.IMAGE }} gw-tools --version | |
docker run --rm ${{ env.IMAGE }} ckb --version | |
docker run --rm ${{ env.IMAGE }} ckb-cli --version | |
docker run --rm ${{ env.IMAGE }} find /scripts -type f -exec sha1sum {} \; | |
- name: Record image info to the outputs of this jobs | |
id: result | |
run: | | |
echo "::set-output name=image_name::`echo ${{ fromJSON(steps.meta.outputs.json).tags[0] }} | awk -F ':' '{print $1}'`" | |
echo "::set-output name=image_tag::`echo ${{ fromJSON(steps.meta.outputs.json).tags[0] }} | awk -F ':' '{print $NF}'`" | |
integration-test: | |
needs: docker-build-push | |
uses: nervosnetwork/godwoken-tests/.github/workflows/reusable-integration-test-v0.yml@develop | |
with: | |
gw_prebuild_image_name: ${{ needs.docker-build-push.outputs.image_name }} | |
gw_prebuild_image_tag: ${{ needs.docker-build-push.outputs.image_tag }} | |
# gw_prebuild_image_digest: ${{ needs.docker-build-push.outputs.image_digest }} |