Skip to content

Commit

Permalink
ci(repo): add job for publishing docker images
Browse files Browse the repository at this point in the history
This commit ensures we cross-build the docker images for linux's arm
and amd platforms and publish them from our Github release workflow.
  • Loading branch information
Jurshsmith committed Jul 3, 2024
1 parent adca72b commit ad42fe2
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 13 deletions.
107 changes: 96 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Release

on:
pull_request:
types: [closed]
branches: [main]
on: push

jobs:
build-artifacts:
Expand Down Expand Up @@ -58,19 +55,107 @@ jobs:
contents: read
actions: write
steps:
- uses: actions/checkout@v4.1.6
- uses: actions/download-artifact@v4.1.7
- name: Checkout Repository
uses: actions/checkout@v4.1.6

- name: Download Artifacts
uses: actions/download-artifact@v4.1.7
with:
path: artifacts
merge-multiple: true

- name: List artifacts
- name: List Artifacts
run: ls -R artifacts

- uses: knope-dev/action@v2.1.0
- name: Cache Artifacts
uses: actions/cache@v3
with:
path: artifacts
key: ${{ runner.os }}-artifacts-${{ github.sha }}
restore-keys: |
${{ runner.os }}-artifacts-
- name: Run Knope Action
uses: knope-dev/action@v2.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.REPO_TOKEN }}

- run: knope release
- name: Knope Release
run: knope release
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
github-token: ${{ secrets.REPO_TOKEN }}

publish-crates:
needs: [release]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: buildjet-4vcpu-ubuntu-2204

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Restore Artifacts Cache
uses: actions/cache@v3
with:
path: artifacts
key: ${{ runner.os }}-artifacts-${{ github.sha }}
restore-keys: |
${{ runner.os }}-artifacts-
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: wasm32-unknown-unknown

- name: Publish Crate
uses: FuelLabs/publish-crates@v1
with:
publish-delay: 60000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

publish-docker-image:
runs-on: buildjet-4vcpu-ubuntu-2204
permissions:
contents: read
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/fuellabs/fuel-core-nats
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{raw}}
type=raw,value=sha-{{sha}}-{{date 'YYYYMMDDhhmmss'}}
flavor: |
latest=${{ github.ref == 'refs/heads/master' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the ghcr.io registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REPO_TOKEN }}

- name: Build and push the image to ghcr.io
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
file: docker/fuel-core-nats.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/fuellabs/fuel-core-nats-docker-build-cache:latest
cache-to: type=registry,ref=ghcr.io/fuellabs/fuel-core-nats-docker-build-cache:latest,mode=max
1 change: 0 additions & 1 deletion docker/fuel-core-nats.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ RUN cargo install cargo-chef && rustup target add wasm32-unknown-unknown
WORKDIR /build/

COPY --from=xx / /

# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.78.0"
components = ["rustfmt", "clippy", "rust-analyzer"]
targets = ["wasm32-unknown-unknown"]
targets = ["wasm32-unknown-unknown", "aarch64-unknown-linux-gnu"]

0 comments on commit ad42fe2

Please sign in to comment.