-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (101 loc) · 3.42 KB
/
release-mia.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Create MIA binary release
# MIA releases are created for tags like `mia-0.1.0`
on:
workflow_dispatch:
push:
tags:
- "mia-[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
# Since we only support x86_64-unknown-linux-gnu for MIA,
# it's fine to hard-code it here now.
env:
TARGET_PLATFORM: x86_64-unknown-linux-gnu
jobs:
x86_64-release:
name: x86_64 release
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout source code
uses: actions/checkout@v4
# Get release version
- name: Get MIA release version from tag name
run: |
VERSION=$(echo "${{ github.ref_name }}" \
| grep -E "^mia-[0-9]+.[0-9]+.[0-9]+$" \
| grep --color=never -Eo "[0-9]+.[0-9]+.[0-9]+$")
if [[ -z $VERSION ]]; then
echo "Ref is not a MIA release tag."
echo "To create MIA release, use tag names like 'mia-0.1.0'."
exit 1;
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Install jq
run: sudo apt-get install -y jq
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ env.TARGET_PLATFORM }}
- name: Get MIA crate version
run: |
cd mia
CARGO_VERSION=$(cargo metadata \
--format-version=1 \
--no-deps \
| jq \
--raw-output \
'.packages[] | select(.name == "mia") | .version')
echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_ENV
- name: Check tag name is aligned with Cargo.toml version
run: |
if [[ "$CARGO_VERSION" != "$VERSION" ]]; then
echo "Tag name is not aligned with MIA crate version."
echo "Please ensure that Cargo.toml version is updated."
exit 1;
fi
- name: Print release version
run: echo $VERSION
# Install binary dependencies
- name: Install buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
# Build sources
- name: Build MIA
run: |
cd mia
cargo build --release --target $TARGET_PLATFORM
# Package MIA
- name: Archive artifacts
id: artifacts
run: |
ARCHIVE_NAME="mia-$VERSION-$TARGET_PLATFORM.tar.gz"
mkdir release
cp ./mia/target/$TARGET_PLATFORM/release/mia ./release/
tar -C ./release -cz -f $ARCHIVE_NAME .
echo "mia=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
- name: Calculate SHA256 checksum
id: checksums
run: |
CHECKSUM_NAME=${{ steps.artifacts.outputs.mia }}.sha256
sha256sum ${{ steps.artifacts.outputs.mia }} | cut -d " " -f 1 > $CHECKSUM_NAME
echo "mia_checksum=$CHECKSUM_NAME" >> $GITHUB_OUTPUT
# Create GitHub release
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: gh release create ${{ github.ref_name }} --title "mia-$VERSION"
- name: Upload release assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
gh release upload ${{ github.ref_name }} \
${{ steps.artifacts.outputs.mia }} \
${{ steps.checksums.outputs.mia_checksum }}