ci(repo): add job for publishing docker images #49
Workflow file for this run
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: Release | |
on: push | |
jobs: | |
build-artifacts: | |
env: | |
archive_name: artifact | |
strategy: | |
fail-fast: false | |
matrix: | |
pkg: [fuel-core-nats] | |
os: [ubuntu-latest] | |
target: [x86_64-unknown-linux-gnu] | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.pkg }} ${{ matrix.target }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: ./.github/actions/setup-rust | |
with: | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
- name: Install host target | |
run: rustup target add ${{ matrix.target }} | |
- name: Build | |
run: make build TARGET=${{ matrix.target }} PACKAGE=${{ matrix.pkg }} | |
- name: Set Archive Name | |
id: archive | |
run: echo "archive_name=${{ matrix.pkg }}-${{ matrix.target }}" >> $GITHUB_ENV | |
- name: Create Tar Archive | |
run: | | |
mkdir ${{ env.archive_name }} | |
cp target/${{ matrix.target }}/release/${{ matrix.pkg }} ${{ env.archive_name }} | |
tar -czf ${{ env.archive_name }}.tgz ${{ env.archive_name }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4.3.3 | |
with: | |
name: ${{ matrix.pkg }}-${{ matrix.target }} | |
path: ${{ env.archive_name }}.tgz | |
if-no-files-found: error | |
release: | |
needs: [build-artifacts] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
actions: write | |
steps: | |
- 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 | |
run: ls -R artifacts | |
- 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.REPO_TOKEN }} | |
- name: Knope Release | |
run: knope release | |
env: | |
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 |