-
Notifications
You must be signed in to change notification settings - Fork 2
173 lines (153 loc) · 5.82 KB
/
Copy pathrelease.yml
File metadata and controls
173 lines (153 loc) · 5.82 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v1.0.0)'
required: true
env:
CARGO_TERM_COLOR: always
permissions:
attestations: write
contents: write
id-token: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.release_info.outputs.tag_name }}
steps:
- name: Check if release exists
id: release_info
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.event.inputs.tag || github.ref_name }}
shell: bash
run: |
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
if gh release view "${TAG_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create Release
if: steps.release_info.outputs.exists != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.release_info.outputs.tag_name }}
shell: bash
run: |
gh release create "${TAG_NAME}" \
--repo "${GITHUB_REPOSITORY}" \
--target "${GITHUB_SHA}" \
--title "Release ${TAG_NAME}" \
--notes ""
build-release:
name: Build Release Binaries
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: pickle-fuzzer
asset_name: pickle-fuzzer-linux-x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: pickle-fuzzer
asset_name: pickle-fuzzer-linux-x86_64-musl
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: pickle-fuzzer
asset_name: pickle-fuzzer-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: pickle-fuzzer
asset_name: pickle-fuzzer-macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: pickle-fuzzer.exe
asset_name: pickle-fuzzer-windows-x86_64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_name }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Strip binary (Linux/macOS)
if: matrix.os != 'windows-latest'
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Generate checksum (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
artifact_path="target/${{ matrix.target }}/release/${{ matrix.artifact_name }}"
checksum_path="target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256"
hash="$(sha256sum "$artifact_path" | awk '{print $1}')"
echo "${hash} ${{ matrix.asset_name }}" > "$checksum_path"
- name: Generate checksum (macOS)
if: matrix.os == 'macos-latest'
run: |
artifact_path="target/${{ matrix.target }}/release/${{ matrix.artifact_name }}"
checksum_path="target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256"
hash="$(shasum -a 256 "$artifact_path" | awk '{print $1}')"
echo "${hash} ${{ matrix.asset_name }}" > "$checksum_path"
- name: Generate checksum (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$artifactPath = "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}"
$checksumPath = "target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256"
$hash = (Get-FileHash -Algorithm SHA256 $artifactPath).Hash.ToLower()
"$hash ${{ matrix.asset_name }}" | Out-File -FilePath $checksumPath -Encoding ascii
- name: Prepare release asset
shell: bash
run: |
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" \
"target/${{ matrix.target }}/release/${{ matrix.asset_name }}"
- name: Attest release binary
uses: actions/attest-build-provenance@v2
with:
subject-path: ./target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Upload Release Asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ needs.create-release.outputs.tag_name }}
shell: bash
run: |
gh release upload "${TAG_NAME}" \
"./target/${{ matrix.target }}/release/${{ matrix.asset_name }}" \
--repo "${GITHUB_REPOSITORY}" \
--clobber
- name: Upload checksum asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ needs.create-release.outputs.tag_name }}
shell: bash
run: |
gh release upload "${TAG_NAME}" \
"./target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256" \
--repo "${GITHUB_REPOSITORY}" \
--clobber
# publish-crate:
# name: Publish to crates.io
# needs: build-release
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Install Rust toolchain
# uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7
# - name: Publish to crates.io
# run: cargo publish --token ${{ secrets.CARGO_TOKEN }}
# continue-on-error: true