Skip to content

Commit 86d9da6

Browse files
committed
add cd
1 parent 41836a0 commit 86d9da6

3 files changed

Lines changed: 135 additions & 1 deletion

File tree

.github/workflows/cd.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*.*.*"]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
10+
cancel-in-progress: false
11+
12+
permissions:
13+
contents: write # to update the release
14+
packages: write # to pull and push images
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
19+
20+
jobs:
21+
build-binaries:
22+
name: Build ${{ matrix.arch }} binaries
23+
runs-on: ${{ matrix.runner }}
24+
strategy:
25+
matrix:
26+
include:
27+
- arch: amd64
28+
runner: ubuntu-24.04
29+
target: x86_64-unknown-linux-gnu
30+
- arch: arm64
31+
runner: ubuntu-24.04-arm
32+
target: aarch64-unknown-linux-gnu
33+
steps:
34+
- name: Free up space
35+
run: sudo rm -rf /opt/hostedtoolcache /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/.ghcup || true
36+
- uses: actions/checkout@v6
37+
with:
38+
submodules: recursive
39+
40+
- name: Configure toolchain
41+
run: |
42+
rustup toolchain install --profile minimal --no-self-update stable
43+
rustup default stable
44+
rustup target add ${{ matrix.target }}
45+
46+
- uses: taiki-e/install-action@v2
47+
with:
48+
tool: just
49+
50+
- uses: Swatinem/rust-cache@v2
51+
with:
52+
key: ${{ matrix.arch }}-release
53+
54+
- name: Build binaries
55+
run: cargo build --locked --target ${{ matrix.target }} --release --bin operator
56+
env:
57+
RUSTFLAGS: "-C target-feature=+crt-static"
58+
59+
- name: Prepare artifacts
60+
run: |
61+
mkdir -p artifacts/${{ matrix.arch }}
62+
cp target/${{ matrix.target }}/release/operator artifacts/${{ matrix.arch }}/
63+
64+
- uses: actions/upload-artifact@v5
65+
with:
66+
name: binaries-${{ matrix.arch }}
67+
path: artifacts/${{ matrix.arch }}/
68+
retention-days: 1
69+
70+
build-images:
71+
name: Build container images
72+
runs-on: ubuntu-24.04
73+
needs: [build-binaries]
74+
steps:
75+
- name: Login to ghcr.io
76+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
77+
78+
- uses: actions/checkout@v6
79+
with:
80+
submodules: recursive
81+
82+
- name: Extract version
83+
id: version
84+
run: echo "version=$(cargo pkgid | cut -d# -f2)" >> "$GITHUB_OUTPUT"
85+
86+
- name: Download AMD64 binaries
87+
uses: actions/download-artifact@v6
88+
with:
89+
name: binaries-amd64
90+
path: .github/build-context/amd64/
91+
92+
- name: Download ARM64 binaries
93+
uses: actions/download-artifact@v6
94+
with:
95+
name: binaries-arm64
96+
path: .github/build-context/arm64/
97+
98+
- name: Debug build context structure
99+
run: |
100+
echo "=== Build context structure ==="
101+
ls -laR .github/build-context/
102+
echo "=== AMD64 binaries ==="
103+
ls -lh .github/build-context/amd64/
104+
echo "=== ARM64 binaries ==="
105+
ls -lh .github/build-context/arm64/
106+
107+
- name: Setup buildkit
108+
uses: docker/setup-buildx-action@v3
109+
110+
- uses: docker/metadata-action@v5
111+
id: meta
112+
with:
113+
images: ghcr.io/beyondessential/postgres-restore-operator
114+
tags: |
115+
type=semver,value=v${{ steps.version.outputs.version }},pattern={{version}}
116+
type=semver,value=v${{ steps.version.outputs.version }},pattern={{major}}.{{minor}}
117+
type=semver,value=v${{ steps.version.outputs.version }},pattern={{major}}
118+
labels: |
119+
org.opencontainers.image.vendor=BES
120+
org.opencontainers.image.title=Postgres Restore Operator
121+
org.opencontainers.image.url=https://github.com/beyondessential/postgres-restore-operator/
122+
org.opencontainers.image.source=https://github.com/beyondessential/postgres-restore-operator/
123+
org.opencontainers.image.version=${{ steps.version.outputs.version }}
124+
org.opencontainers.image.licenses=GPL-3.0-or-later
125+
126+
- name: Build and push
127+
uses: docker/build-push-action@v6
128+
with:
129+
context: .github/build-context
130+
file: .github/Dockerfile.native
131+
platforms: linux/amd64,linux/arm64
132+
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
133+
labels: ${{ steps.meta.outputs.labels }}
134+
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
env:
1313
CARGO_TERM_COLOR: always
14-
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
14+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
1515

1616
concurrency:
1717
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
File renamed without changes.

0 commit comments

Comments
 (0)