-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (92 loc) · 3.79 KB
/
release.yml
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:
workflow_dispatch:
inputs:
release: # e.g. 'v0.8.0'
description: try-runtime release tag
required: true
title: # e.g. 'try-runtime-cli v0.8.0'
description: Release title
required: true
jobs:
build:
runs-on: ${{ matrix.platform.os }}
permissions:
contents: write
strategy:
matrix:
package:
- try-runtime-cli
platform:
# Linux
- os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
# macOS
- os: macos-14
target: aarch64-apple-darwin
- os: macos-14
target: x86_64-apple-darwin
env:
RUSTFLAGS: "${{ matrix.platform.cpu != '' && format('-C target-cpu={0}', matrix.platform.cpu) || '' }} ${{ matrix.platform.target == 'aarch64-unknown-linux-gnu' && '-C linker=aarch64-linux-gnu-gcc' || '' }}"
path: "target/${{ matrix.platform.target }}/release"
archive: "${{ matrix.package }}-${{ matrix.platform.target }}${{ matrix.platform.cpu != '' && format('-{0}', matrix.platform.cpu) || '' }}.tar.gz"
sha: ${{ contains(matrix.platform.target, 'apple') && 'shasum -a 256' || 'sha256sum' }}
steps:
- name: Free up space
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# Clone and checkout release
- id: clone
name: Clone release
run: |
git clone --branch ${{ github.event.inputs.release }} --depth 1 https://github.com/paritytech/try-runtime-cli
cd try-runtime-cli
echo "rev=$(git rev-parse --short HEAD | tr -d '\n')" >> "$GITHUB_OUTPUT"
# Install packages
- name: Install packages (Linux)
if: contains(matrix.platform.target, 'linux')
run: |
sudo apt-get update -y
sudo apt-get install -y --fix-missing protobuf-compiler ${{ contains(matrix.platform.target, 'aarch64') && 'crossbuild-essential-arm64' || '' }}
- name: Install packages (macOS)
if: contains(matrix.platform.target, 'apple')
run: brew install protobuf
# Configure Rust toolchain
- name: Set Rust version
run: |
rustup default stable
rustup component add rust-src
rustup target add ${{ matrix.platform.target }} wasm32-unknown-unknown
# Build and package
- name: Build ${{ matrix.package }}
working-directory: try-runtime-cli
run: |
cargo b --profile=release -p ${{ matrix.package }} --target ${{ matrix.platform.target }}
- name: Package try-runtime
working-directory: try-runtime-cli/${{ env.path }}
run: |
mv try-runtime try-runtime-cli
${{ env.sha }} try-runtime-cli > try-runtime.sha256
tar -czf ${{ env.archive }} try-runtime-cli try-runtime.sha256
# Add package to workflow
- name: Upload archives
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.package }}-${{ matrix.platform.target }}
path: |
try-runtime-cli/${{ env.path }}/${{ env.archive }}
# Add package to release
- name: Release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.event.inputs.title }}
tag_name: ${{ github.event.inputs.release }}
body: "Release generated from release tag `${{ github.event.inputs.release }}` (commit: `${{ steps.clone.outputs.rev }}`).\n\nPlease see https://github.com/paritytech/try-runtime-cli/releases/tag/${{ github.event.inputs.release }} for release notes."
files: |
try-runtime-cli/${{ env.path }}/${{ env.archive }}