Repository navigation
136 lines (119 loc) · 5.13 KB
/
Copy pathbinaries.yaml
File metadata and controls
136 lines (119 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
name: build binaries
# Note: this workflow should really depend on a workflow that runs on-platform tests
# because as is what we're doing here is building a binary blind that we have no idea
# whether it works or not beyond being able to just execute the binary.
# This is more important here than in other cases because it's highly likley
# there are _no_ tests being run on most of the platforms we're building here.
on:
push:
branches:
- "ci-test-binaries" # Push changes to this branch to initiate a draft release to test this workflow
tags:
- "[0-9]+.[0-9]+.[0-9]*" # Normal trigger is a tag created of the form x.y.z (note not vx.y.z)
env:
test_branch_name: "ci-test-binaries" # Branch which should be named above, used for release process testing
jobs:
create_release:
name: Create the GitHub Release
permissions:
contents: write # See: https://github.com/orgs/community/discussions/68252
runs-on: ubuntu-latest
outputs:
release-tag: ${{ steps.release-info.outputs.release-tag }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: print build info
run: |
echo "github.ref: ${{ github.ref }}"
echo "test branch: ${{ env.test_branch_name }}"
echo "test run: ${{ endsWith( github.ref, env.test_branch_name ) }}"
shell: bash
- name: generate release info
id: release-info
# For release testing we don't have a version to use from a tag
# so we generate a stand in that's a time stamp
run: |
if [[ ${{ endsWith( github.ref, env.test_branch_name ) }} == 'true' ]]; then
tag=$(date +'%Y%m%d%H%M')
else
# This is a bit of a hack, but we need to get the tag name from the ref
tag=$(echo "${{ github.ref }}" | cut -d'/' -f3)
fi
echo "release-tag: ${tag}"
echo "release-tag=${tag}" >> $GITHUB_OUTPUT
shell: bash
- name: create release
id: create-release
uses: softprops/action-gh-release@v2
with:
draft: ${{ endsWith( github.ref, env.test_branch_name ) }}
tag_name: ${{ steps.release-info.outputs.release-tag }}
generate_release_notes: false # This doesn't seem to work -- it still generates release notes
build:
name: Build and upload binaries
permissions:
contents: write
strategy:
matrix:
# windows-11-arm currently fails build due to https://github.com/0LNetworkCommunity/libra-framework/issues/405
# macos-latest is ARM, ubuntu-latest is x86, windows-latest is x86
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest]
runs-on: ${{ matrix.os }}
needs: create_release
steps:
- name: checkout
uses: actions/checkout@v3
- name: get executable binary_suffix
id: platform-info
run: |
if [[ ${{ runner.os }} == "Windows" ]]; then
binary_suffix=".exe"
else
binary_suffix=""
fi
echo "binary_suffix=${binary_suffix}" >> $GITHUB_OUTPUT
shell: bash
- name: install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1 # We need 1.12.0 or later for Windows ARM64 support
with:
# Provisionally pinning version pre 1.81 sorting changes
toolchain: 1.80.1
override: true
- name: install dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: build-essential ca-certificates clang curl git libpq-dev libssl-dev pkg-config lsof lld
version: 1.0
if: runner.os == 'Linux' # This action only works on Ubuntu
- name: set RUSTFLAGS # Note this is necessary because the setting in .cargo/config.toml doesn't propagate to dependency builds
run: echo "RUSTFLAGS=--cfg tokio_unstable" >> $GITHUB_ENV
shell: bash
- name: build libra binary
run: |
cargo b --release -p libra
- name: check binary runs on this platform
run: target/release/libra version
shell: bash
- name: rename to platform specific name
id: artifact-info
run: |
runner_os=${{ runner.os }}
runner_os_lowercase=${runner_os,,}
runner_arch=${{ runner.arch }}
runner_arch_lowercase=${runner_arch,,}
artifact_name=target/release/libra-${runner_os_lowercase}-${runner_arch_lowercase}${{ steps.platform-info.outputs.binary_suffix }}
echo "artifact_name=${artifact_name}" >> $GITHUB_OUTPUT
build_output=target/release/libra${binary_suffix}
echo "Renaming: ${build_output} to: ${artifact_name}"
mv ${build_output} ${artifact_name}
shell: bash
- name: print binary artifact name
run: |
echo "artifact_name: ${{ steps.artifact-info.outputs.artifact_name }}"
shell: bash
- name: upload binary to release # upload the binary as a release artifact
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.create_release.outputs.release-tag }}
files: ${{ steps.artifact-info.outputs.artifact_name }}