-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (132 loc) · 5.3 KB
/
release.yml
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
142
143
144
145
name: Release
on:
push:
branches: [main]
tags:
- "v*.*.*"
create:
tags:
- "v*.*.*"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
APP_NAME: sdf
ARTIFACT_DIR: release-builds
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-release:
name: build-release
runs-on: ${{ matrix.os }}
env:
RUST_BACKTRACE: 1
strategy:
matrix:
build:
- linux gnu x64
- linux gnu aarch64
include:
- build: linux gnu x64
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
cross: false
- build: linux gnu aarch64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
cross: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install dev-tools
run: sudo apt-get install -y --no-install-recommends build-essential pkg-config libssl-dev
- name: Install deps
run: cargo install bpf-linker
- name: Build ebpf
run: cargo xtask build-ebpf
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --verbose --release --package ${{ env.APP_NAME }} --target ${{ matrix.target }}
- name: Rename file
run: mv ./target/${{ matrix.target }}/release/${{ env.APP_NAME }} ${{ env.APP_NAME }}-${{ matrix.target }}
- name: Upload Artifact to Summary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: ${{ env.APP_NAME }}-${{ matrix.target }}
- name: Upload binaries to release
if: startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.APP_NAME }}-${{ matrix.target }}
asset_name: ${{ env.APP_NAME }}-${{ matrix.target }}
tag: ${{ github.ref }}
overwrite: true
create-release:
# only run if not a tags build
if: startsWith(github.ref, 'refs/tags/') == false
needs: build-release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- name: Display structure of downloaded files
run: ls -R
- name: create_release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ github.event_name == 'workflow_dispatch' && 'latest' || (github.ref == 'refs/heads/main' && 'latest') || github.ref }}
title: Build ${{ github.event_name == 'workflow_dispatch' && 'development' || github.ref }}
files: |
*/*
prerelease: true
deploy-docker:
needs: build-release
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}