forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (76 loc) · 3.43 KB
/
docker-publish.yml
File metadata and controls
84 lines (76 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: docker
permissions: {}
on:
# Trigger without any parameters a proactive rebuild
workflow_dispatch: {}
workflow_call:
inputs:
tag_name:
required: true
type: string
env:
REGISTRY: ghcr.io
# Will resolve to foundry-rs/foundry
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: build and push
runs-on: depot-ubuntu-22.04-16
permissions:
contents: read
id-token: write
packages: write
timeout-minutes: 120
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # master
with:
toolchain: stable
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
- name: Install gcc aarch64
id: aarch_64_setup
run: |
sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login into registry ${{ env.REGISTRY }}
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Creates an additional 'latest' or 'nightly' tag
# If the job is triggered via cron schedule, tag nightly and nightly-{SHA}
# If the job is triggered via workflow dispatch and on a master branch, tag branch and latest
# Otherwise, just tag as the branch name
- name: Finalize Docker Metadata
id: docker_tagging
run: |
if [[ "${{ github.event_name }}" == "schedule" ]]; then
printf "cron trigger, assigning nightly tag\n"
printf "docker_tags=%s/%s:nightly,%s/%s:nightly-%s\n" "${{ env.REGISTRY }}" "${{ env.IMAGE_NAME }}" "${{ env.REGISTRY }}" "${{ env.IMAGE_NAME }}" "$GITHUB_SHA" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ "${GITHUB_REF##*/}" == "master" ]]; then
printf "manual trigger from master/main branch, assigning latest tag\n"
printf "docker_tags=%s/%s:%s,%s/%s:latest\n" "${{ env.REGISTRY }}" "${{ env.IMAGE_NAME }}" "${GITHUB_REF##*/}" "${{ env.REGISTRY }}" "${{ env.IMAGE_NAME }}" >> "$GITHUB_OUTPUT"
else
printf "Neither scheduled nor manual release from main branch. Just tagging as branch name\n"
printf "docker_tags=%s/%s:%s\n" "${{ env.REGISTRY }}" "${{ env.IMAGE_NAME }}" "${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT"
fi
# Log docker metadata to explicitly know what is being pushed
- name: Inspect Docker Metadata
run: |
printf "TAGS -> %s\n" "${{ steps.docker_tagging.outputs.docker_tags }}"
printf "LABELS -> %s\n" "${{ steps.meta.outputs.labels }}"
- name: Build and push foundry image
run: make DOCKER_IMAGE_NAME=${{ steps.docker_tagging.outputs.docker_tags }} CARGO_TAG_NAME=${{ inputs.tag_name }} PROFILE=maxperf docker-build-push