-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (133 loc) · 4.47 KB
/
Copy pathrelease.yml
File metadata and controls
152 lines (133 loc) · 4.47 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g. v0.1.0)'
required: true
type: string
# REPLACE these per-project:
env:
# Path to the CLI crate inside joulesperbit
CLI_CRATE_PATH: crates/flowg-cli
# Name of the CLI binary that ends up in target/release/
BIN_NAME: flowg
# Public name (what the tarball is named)
RELEASE_NAME: flowg
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-14
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-14
archive: tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
archive: tar.gz
use-cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
archive: tar.gz
use-cross: true
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- name: Resolve tag
id: tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
fi
- name: Checkout public release surface
uses: actions/checkout@v4
- name: Checkout private source
uses: actions/checkout@v4
with:
repository: openIE-dev/joulesperbit
token: ${{ secrets.JOULESPERBIT_READ_TOKEN }}
path: joulesperbit
ref: ${{ steps.tag.outputs.tag }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross (Linux only)
if: matrix.use-cross
run: cargo install cross --locked
- name: Build
shell: bash
working-directory: joulesperbit
run: |
if [ "${{ matrix.use-cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }} -p "${CLI_CRATE_PATH##*/}"
else
cargo build --release --target ${{ matrix.target }} -p "${CLI_CRATE_PATH##*/}"
fi
- name: Package
shell: bash
run: |
STAGE=$(mktemp -d)
TAG="${{ steps.tag.outputs.tag }}"
BASE="${RELEASE_NAME}-${TAG#v}-${{ matrix.target }}"
mkdir -p "$STAGE/$BASE"
if [ "${{ matrix.target }}" = "x86_64-pc-windows-msvc" ]; then
cp "joulesperbit/target/${{ matrix.target }}/release/${BIN_NAME}.exe" "$STAGE/$BASE/"
else
cp "joulesperbit/target/${{ matrix.target }}/release/${BIN_NAME}" "$STAGE/$BASE/"
fi
cp LICENSE README.md "$STAGE/$BASE/" 2>/dev/null || true
cd "$STAGE"
if [ "${{ matrix.archive }}" = "zip" ]; then
(cd "$BASE" && 7z a -tzip "../${BASE}.zip" .)
mv "${BASE}.zip" "${{ github.workspace }}/"
(cd "${{ github.workspace }}" && shasum -a 256 "${BASE}.zip" > "${BASE}.zip.sha256")
else
tar czf "${BASE}.tar.gz" "$BASE"
mv "${BASE}.tar.gz" "${{ github.workspace }}/"
(cd "${{ github.workspace }}" && shasum -a 256 "${BASE}.tar.gz" > "${BASE}.tar.gz.sha256")
fi
ls -la "${{ github.workspace }}"/*${BASE}*
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_NAME }}-${{ matrix.target }}
path: |
${{ env.RELEASE_NAME }}-*-${{ matrix.target }}.tar.gz*
${{ env.RELEASE_NAME }}-*-${{ matrix.target }}.zip*
release:
name: Publish Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Collect
run: |
mkdir -p dist
find artifacts -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name '*.sha256' \) -exec mv {} dist/ \;
ls -la dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
fail_on_unmatched_files: true