-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (116 loc) · 3.84 KB
/
Copy pathci.yaml
File metadata and controls
141 lines (116 loc) · 3.84 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
env:
SUFFIX: ${{ (github.head_ref || github.ref_name) == 'main' && '' || format('-{0}', replace(github.head_ref || github.ref_name, '[^0-9A-Za-z_-]', '-')) }}
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo check
- run: cargo fmt -- --check
- run: cargo clippy -- -D warnings
build:
strategy:
matrix:
arch: [x86_64, aarch64]
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
container: amazonlinux:2023
permissions:
contents: read
steps:
- run: dnf update -y && dnf install -y git tar gcc pkg-config openssl-devel
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo build --release
- run: mkdir -p target/opt/extensions
- run: cp target/release/diet-lambda target/opt/extensions/diet-lambda
- uses: actions/upload-artifact@v7
with:
name: diet-lambda-${{ matrix.arch }}
path: target/opt
staging:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
strategy:
matrix:
arch: [x86_64, aarch64]
permissions:
contents: read
id-token: write
steps:
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.LAMBDA_STAGE_PUBLISHER_ARN }}
aws-region: us-east-1
- uses: actions/download-artifact@v8
id: download
with:
name: diet-lambda-${{ matrix.arch }}
skip-decompress: true
- name: Publish layer
run: |
LAYER_ARN=$(
aws lambda publish-layer-version \
--layer-name diet-lambda-${{ matrix.arch }}$SUFFIX \
--license-info "Apache 2.0" \
--compatible-architectures ${{ matrix.arch == 'x86_64' && 'x86_64' || 'arm64' }} \
--zip-file fileb://${{ steps.download.outputs.download-path }}/diet-lambda-${{ matrix.arch }}.zip \
--query 'LayerVersionArn' \
--output text
)
echo "::notice::$LAYER_ARN"
docker:
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
strategy:
matrix:
arch: [x86_64, aarch64]
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v8
with:
name: diet-lambda-${{ matrix.arch }}
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ matrix.arch }}$SUFFIX
multiarch:
needs: docker
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
docker buildx imagetools create \
--tag ghcr.io/${{ github.repository }}:latest$SUFFIX \
ghcr.io/${{ github.repository }}:x86_64$SUFFIX \
ghcr.io/${{ github.repository }}:aarch64$SUFFIX