-
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (83 loc) · 2.6 KB
/
release.yaml
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
name: Release
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
# https://github.com/actions/cache/blob/main/examples.md#rust---cargo
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ runner.arch }}-binary
path: target/release/m8s
release-binary:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Linux binary
uses: actions/download-artifact@v4
with:
name: Linux-X64-binary
path: ./binaries-linux-x64
- name: Download macOS binary
uses: actions/download-artifact@v4
with:
name: macOS-ARM64-binary
path: ./binaries-macos-arm64
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -ex
gh release create "${{ github.ref_name }}" -t "${{ github.ref_name }}" --generate-notes
mv ./binaries-linux-x64/m8s ./binaries-linux-x64/m8s-linux-x64
gh release upload "${{ github.ref_name }}" ./binaries-linux-x64/m8s-linux-x64
mv ./binaries-macos-arm64/m8s ./binaries-macos-arm64/m8s-macos-arm64
gh release upload "${{ github.ref_name }}" ./binaries-macos-arm64/m8s-macos-arm64
release-docker:
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ github.ref_name }}