-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (99 loc) · 3.13 KB
/
Copy pathrelease.yml
File metadata and controls
113 lines (99 loc) · 3.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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag name for the draft release"
required: true
type: string
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
package: patchsplit-linux-x86_64
asset: patchsplit-linux-x86_64.tar.gz
archive: tar.gz
binary: patchsplit
- name: macOS x86_64
os: macos-latest
target: x86_64-apple-darwin
package: patchsplit-macos-x86_64
asset: patchsplit-macos-x86_64.tar.gz
archive: tar.gz
binary: patchsplit
- name: Windows x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
package: patchsplit-windows-x86_64
asset: patchsplit-windows-x86_64.zip
archive: zip
binary: patchsplit.exe
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Test
run: cargo test --target ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package Unix
if: matrix.archive == 'tar.gz'
shell: bash
run: |
set -euo pipefail
mkdir -p dist
cp "target/${{ matrix.target }}/release/${{ matrix.binary }}" dist/
chmod +x "dist/${{ matrix.binary }}"
tar -czf "${{ matrix.package }}.tar.gz" -C dist "${{ matrix.binary }}"
- name: Package Windows
if: matrix.archive == 'zip'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item "target/${{ matrix.target }}/release/${{ matrix.binary }}" dist/
Compress-Archive -Path "dist/${{ matrix.binary }}" -DestinationPath "${{ matrix.package }}.zip" -Force
- name: Upload Package
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}
path: ${{ matrix.asset }}
if-no-files-found: error
draft-release:
name: Create Draft Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Packages
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create Draft Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
RELEASE_REPOSITORY: ${{ github.repository }}
run: |
gh release create "$RELEASE_TAG" artifacts/* \
--repo "$RELEASE_REPOSITORY" \
--draft \
--target "$GITHUB_SHA" \
--title "$RELEASE_TAG" \
--generate-notes