-
Notifications
You must be signed in to change notification settings - Fork 1
171 lines (146 loc) · 5.13 KB
/
release.yml
File metadata and controls
171 lines (146 loc) · 5.13 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Release
on:
push:
branches:
- 'main'
paths:
- 'CHANGELOG.md' # Only trigger when this file is modified
permissions: {}
env:
CARGO_TERM_COLOR: always
RELEASE_BIN: mira-oxide
REGISTRY: ghcr.io
jobs:
create-release:
name: Create New Release
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Extract Changelog
id: extract_changelog
shell: bash
run: perl .github/scripts/last_release_notes.pl > $RUNNER_TEMP/release_notes.md
- name: Create Release
id: create_release
shell: bash
run: |
[[ "${{ github.ref_name }}" == "test" ]] && latest="--latest=false" || latest=
gh release create "${{ github.ref_name }}" \
--title "${RELEASE_BIN} ${{ github.ref_name }}" \
--notes-file "$RUNNER_TEMP/release_notes.md" \
$latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-release-image-and-linux-artifacts:
name: Build Linux Artifacts and Images
needs: [create-release]
strategy:
matrix:
include:
- arch: x86_64
runner: ubuntu-latest
- arch: aarch64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=raw,value=latest-${{ matrix.arch }}
- name: Debug Git ref
run: |
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_REF_NAME: $GITHUB_REF_NAME"
echo "GITHUB_SHA: $GITHUB_SHA"
echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
file: Dockerfile
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Prepare Linux Binary
shell: bash
run: |
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | grep -- '-${{ matrix.arch }}$' | head -n 1)
docker create --name temp-container $IMAGE_TAG \
&& docker cp temp-container:/app/${RELEASE_BIN} ./${RELEASE_BIN} \
&& docker rm temp-container \
&& tar -czf ${RELEASE_BIN}-linux-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz ${RELEASE_BIN}
- name: Upload Linux Release Asset
shell: bash
run: |
gh release upload "${{ github.ref_name }}" ${RELEASE_BIN}-linux-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-image-manifest:
name: Create Image Manifest
needs: build-release-image-and-linux-artifacts
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifests
shell: bash
run: |
REPO=$(echo "${{ env.REGISTRY }}/${{ github.repository }}" | tr '[A-Z]' '[a-z]')
VERSION=${REPO}:${{ github.ref_name }}
LATEST=${REPO}:latest
docker manifest create $VERSION --amend ${LATEST}-x86_64 --amend ${LATEST}-aarch64 \
&& docker manifest push $VERSION
docker manifest create $LATEST --amend ${LATEST}-x86_64 --amend ${LATEST}-aarch64 \
&& docker manifest push $LATEST
build-mac-artifacts:
name: Build Mac Artifacts
needs: create-release
runs-on: macos-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install latest nightly Rust
run: |
rustup update nightly
rustup default nightly
rustup target add aarch64-apple-darwin x86_64-apple-darwin
- name: Build
run: |
cargo build --release --target aarch64-apple-darwin --target x86_64-apple-darwin
- name: Package Binary
shell: bash
run: |
lipo -create -output ${{ env.RELEASE_BIN }} \
target/aarch64-apple-darwin/release/${{ env.RELEASE_BIN }} \
target/x86_64-apple-darwin/release/${{ env.RELEASE_BIN }}
tar -czf ${{ env.RELEASE_BIN }}-apple-universal-${{ github.ref_name }}.tar.gz ${{ env.RELEASE_BIN }}
- name: Upload Release Asset
shell: bash
run: |
gh release upload "${{ github.ref_name }}" ${{ env.RELEASE_BIN }}-apple-universal-${{ github.ref_name }}.*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}