-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (124 loc) · 4.17 KB
/
release.yml
File metadata and controls
132 lines (124 loc) · 4.17 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
name: Publish
on:
push:
branches:
- master
tags:
- "v*.*.*"
pull_request:
jobs:
publish:
name: Publish for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: oha
release_name: oha-linux-amd64
target: x86_64-unknown-linux-musl
additional_args: "--features vsock"
use_cross: false
- os: windows-latest
artifact_name: oha.exe
release_name: oha-windows-amd64.exe
target: x86_64-pc-windows-msvc
additional_args: ""
use_cross: false
- os: macos-latest
artifact_name: oha
release_name: oha-macos-amd64
target: x86_64-apple-darwin
additional_args: ""
use_cross: false
- os: ubuntu-latest
artifact_name: oha
release_name: oha-linux-arm64
target: aarch64-unknown-linux-musl
additional_args: "--features vsock"
use_cross: true
- os: macos-14
artifact_name: oha
release_name: oha-macos-arm64
target: aarch64-apple-darwin
additional_args: ""
use_cross: false
env:
BUILD_CMD: cargo
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v6
- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.target, 'musl')
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.use_cross
uses: taiki-e/install-action@v2
with:
tool: cross
- uses: Swatinem/rust-cache@v2
- name: Overwrite build command env variable
if: matrix.use_cross
shell: bash
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
- name: Build
shell: bash
run: $BUILD_CMD build --profile release-ci --target ${{ matrix.target }} --locked --no-default-features --features rustls ${{ matrix.additional_args }}
- name: Upload
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.release_name }}
path: target/${{ matrix.target }}/release-ci/${{ matrix.artifact_name }}
- name: Upload binaries to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.target }}/release-ci/${{ matrix.artifact_name }}
asset_name: ${{ matrix.release_name }}
tag: ${{ github.ref }}
docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: publish
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max