-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (126 loc) · 4.83 KB
/
release-cli.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
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
name: Build and release CLI
on:
release:
types: [created]
workflow_dispatch:
inputs:
app_version:
description: Semantic version of release
required: true
type: string
defaults:
run:
shell: bash
permissions:
actions: write
contents: write
jobs:
build:
if: (github.event_name == 'release' && startsWith(github.ref_name, 'cli-')) || inputs.app_version != ''
name: build (${{ matrix.platform.target_alt }})
timeout-minutes: 10
outputs:
app_name: ${{ steps.set-build-info.outputs.app_name }}
app_version: ${{ steps.set-build-info.outputs.app_version }}
strategy:
matrix:
platform:
- os: macos-latest
target: aarch64-apple-darwin
target_alt: darwin-arm64
bin_name: beam
- os: macos-latest
target: x86_64-apple-darwin
target_alt: darwin-amd64
bin_name: beam
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
target_alt: linux-amd64
bin_name: beam
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
target_alt: linux-arm64
bin_name: beam
- os: windows-latest
target: x86_64-pc-windows-msvc
target_alt: windows-amd64
bin_name: beam.exe
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set build info
id: set-build-info
run: |
app_name=${{ matrix.platform.bin_name }}
echo "app_name=${app_name%.exe}" >> $GITHUB_OUTPUT
if [[ ! -z "${{ inputs.app_version }}" ]]; then
echo "app_version=${{ inputs.app_version }}" >> $GITHUB_OUTPUT
else
echo "app_version=${GITHUB_REF_NAME#cli-}" >> $GITHUB_OUTPUT
fi
- name: Setup Rust
uses: moonrepo/setup-rust@v1
with:
targets: "${{ matrix.platform.target }}"
- name: Setup PyApp
env:
PYAPP_VERSION: 0.22.0
run: |
curl -L -o pyapp.tar.gz https://github.com/ofek/pyapp/releases/download/v${PYAPP_VERSION}/source.tar.gz
tar -xzf pyapp.tar.gz
mv pyapp-v* pyapp-latest
- name: Build binary
uses: houseabsolute/[email protected]
env:
PYAPP_PROJECT_NAME: "beam-client"
PYAPP_EXEC_MODULE: "${{ steps.set-build-info.outputs.app_name }}"
PYAPP_PROJECT_VERSION: "${{ steps.set-build-info.outputs.app_version }}"
PYAPP_FULL_ISOLATION: "true"
PYAPP_DISTRIBUTION_EMBED: "true"
with:
command: "build"
args: "--release --locked"
target: "${{ matrix.platform.target }}"
strip: true
working-directory: pyapp-latest
- name: Prepare artifact
id: prepare-artifact
env:
GZIP: "-9"
run: |
mv -v pyapp-latest/target/${{ matrix.platform.target }}/release/pyapp pyapp-latest/target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin_name }}
cp -v pyapp-latest/target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin_name }} .
tar -cvzf ${{ matrix.platform.bin_name }}-${{ steps.set-build-info.outputs.app_version }}-${{ matrix.platform.target_alt }}.tar.gz ${{ matrix.platform.bin_name }}
echo "tar_file_path=$(pwd)/${{ matrix.platform.bin_name }}-${{ steps.set-build-info.outputs.app_version }}-${{ matrix.platform.target_alt }}.tar.gz" >> $GITHUB_OUTPUT
- name: Upload artifact to actions run
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-build-info.outputs.app_name }}-${{ steps.set-build-info.outputs.app_version }}-${{ matrix.platform.target_alt }}
path: ${{ matrix.platform.bin_name }}
if-no-files-found: ignore
compression-level: "9"
- name: Upload artifact to release
if: github.event_name == 'release' && startsWith(github.ref_name, 'cli-')
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload ${GITHUB_REF_NAME} "${{ steps.prepare-artifact.outputs.tar_file_path }}"
formula:
if: github.event_name == 'release' && startsWith(github.ref_name, 'cli-')
needs: build
runs-on: ubuntu-latest
steps:
- name: Send update formula event
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.DISPATCH_TO_HOMEBREW_BEAM_GH_TOKEN }}
repository: beam-cloud/homebrew-beam
event-type: update-formula
client-payload: |-
{
"name": "${{ needs.build.outputs.app_name }}",
"version": "${{ needs.build.outputs.app_version }}",
"tag": "${{ github.ref_name }}",
"repo": "${{ github.repository }}"
}