Skip to content

Commit e19171e

Browse files
committed
Add new release workflow (roughly based on IRMA-core's)
1 parent 12d8e2b commit e19171e

File tree

2 files changed

+178
-0
lines changed

2 files changed

+178
-0
lines changed

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.x86_64-apple-darwin]
2+
rustflags = ["-C", "link-arg=-mmacosx-version-min=10.14"]
3+
4+
[target.aarch64-apple-darwin]
5+
rustflags = ["-C", "link-arg=-mmacosx-version-min=11.0"]

.github/workflows/release.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- test
8+
9+
permissions: {}
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
RELEASE_BIN: mira-oxide
14+
REGISTRY: ghcr.io
15+
16+
jobs:
17+
create-release:
18+
name: Create New Release
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
outputs:
23+
upload_url: ${{ steps.create_release.outputs.upload_url }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Extract Changelog
28+
id: extract_changelog
29+
shell: bash
30+
run: perl .github/scripts/last_release_notes.pl > $RUNNER_TEMP/release_notes.md
31+
32+
- name: Create Release
33+
id: create_release
34+
shell: bash
35+
run: |
36+
[[ "${{ github.ref_name }}" == "test" ]] && latest="--latest=false" || latest=
37+
38+
gh release create "${{ github.ref_name }}" \
39+
--title "${RELEASE_BIN} ${{ github.ref_name }}" \
40+
--notes-file "$RUNNER_TEMP/release_notes.md" \
41+
$latest
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
build-release-image-and-linux-artifacts:
46+
name: Build Linux Artifacts and Images
47+
needs: [create-release]
48+
strategy:
49+
matrix:
50+
include:
51+
- arch: x86_64
52+
runner: ubuntu-latest
53+
- arch: aarch64
54+
runner: ubuntu-24.04-arm
55+
runs-on: ${{ matrix.runner }}
56+
permissions:
57+
contents: write
58+
packages: write
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 0
63+
ref: ${{ github.ref }}
64+
65+
- name: Log in to the Container registry
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ${{ env.REGISTRY }}
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Extract metadata for Docker
73+
id: meta
74+
uses: docker/metadata-action@v5
75+
with:
76+
images: ${{ env.REGISTRY }}/${{ github.repository }}
77+
tags: |
78+
type=raw,value=latest-${{ matrix.arch }}
79+
80+
- name: Debug Git ref
81+
run: |
82+
echo "GITHUB_REF: $GITHUB_REF"
83+
echo "GITHUB_REF_NAME: $GITHUB_REF_NAME"
84+
echo "GITHUB_SHA: $GITHUB_SHA"
85+
echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
86+
87+
- name: Build and push Docker image
88+
uses: docker/build-push-action@v6
89+
with:
90+
file: Dockerfile
91+
context: ${{ github.workspace }}
92+
push: true
93+
tags: ${{ steps.meta.outputs.tags }}
94+
95+
- name: Prepare Linux Binary
96+
shell: bash
97+
run: |
98+
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | grep -- '-${{ matrix.arch }}$' | head -n 1)
99+
docker create --name temp-container $IMAGE_TAG \
100+
&& docker cp temp-container:/app/${RELEASE_BIN} ./${RELEASE_BIN} \
101+
&& docker rm temp-container \
102+
&& tar -czf ${RELEASE_BIN}-linux-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz ${RELEASE_BIN}
103+
104+
- name: Upload Linux Release Asset
105+
shell: bash
106+
run: |
107+
gh release upload "${{ github.ref_name }}" ${RELEASE_BIN}-linux-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
111+
create-image-manifest:
112+
name: Create Image Manifest
113+
needs: build-release-image-and-linux-artifacts
114+
runs-on: ubuntu-latest
115+
permissions:
116+
packages: write
117+
contents: read
118+
steps:
119+
- name: Log in to the Container registry
120+
uses: docker/login-action@v3
121+
with:
122+
registry: ${{ env.REGISTRY }}
123+
username: ${{ github.actor }}
124+
password: ${{ secrets.GITHUB_TOKEN }}
125+
126+
- name: Create and push manifests
127+
shell: bash
128+
run: |
129+
REPO=$(echo "${{ env.REGISTRY }}/${{ github.repository }}" | tr '[A-Z]' '[a-z]')
130+
VERSION=${REPO}:${{ github.ref_name }}
131+
LATEST=${REPO}:latest
132+
133+
docker manifest create $VERSION --amend ${LATEST}-x86_64 --amend ${LATEST}-aarch64 \
134+
&& docker manifest push $VERSION
135+
136+
docker manifest create $LATEST --amend ${LATEST}-x86_64 --amend ${LATEST}-aarch64 \
137+
&& docker manifest push $LATEST
138+
139+
build-mac-artifacts:
140+
name: Build Mac Artifacts
141+
needs: create-release
142+
runs-on: macos-latest
143+
144+
permissions:
145+
contents: write
146+
147+
steps:
148+
- uses: actions/checkout@v4
149+
150+
- name: Install latest nightly Rust
151+
run: |
152+
rustup update nightly
153+
rustup default nightly
154+
rustup target add aarch64-apple-darwin x86_64-apple-darwin
155+
156+
- name: Build
157+
run: |
158+
cargo build --release --target aarch64-apple-darwin --target x86_64-apple-darwin
159+
160+
- name: Package Binary
161+
shell: bash
162+
run: |
163+
lipo -create -output ${{ env.RELEASE_BIN }} \
164+
target/aarch64-apple-darwin/release/${{ env.RELEASE_BIN }} \
165+
target/x86_64-apple-darwin/release/${{ env.RELEASE_BIN }}
166+
tar -czf apple-universal-${{ github.ref_name }}.tar.gz ${{ env.RELEASE_BIN }}
167+
168+
- name: Upload Release Asset
169+
shell: bash
170+
run: |
171+
gh release upload "${{ github.ref_name }}" apple-universal-${{ github.ref_name }}.*
172+
env:
173+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)