-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (127 loc) · 4.26 KB
/
release.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
142
143
144
145
146
147
name: Release Artifacts
on:
push:
branches:
- release
jobs:
build:
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- os: ubuntu-latest
tag: linux-amd64
is_version_job: true # Designate one job for versioning
- os: windows-latest
tag: windows-amd64
is_version_job: false
- os: macos-latest
tag: macos-amd64
is_version_job: false
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Install Rust
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
# Build the project
- name: Build the project
run: cargo build --release
# Get the version from Cargo.toml
- name: Get version from Cargo.toml
id: get_version
if: matrix.config.is_version_job == true
run: |
# Extract the version from Cargo.toml
version=$(cargo pkgid | cut -d "@" -f2)
echo "VERSION=$version" >> $GITHUB_ENV
echo "$version" > version.txt
# Upload the binary as an artifact, correctly naming it based on platform
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: runlike-${{ matrix.config.tag }}
path: |
target/release/runlike${{ matrix.config.os == 'windows-latest' && '.exe' || '' }}
- name: Upload version file
if: matrix.config.is_version_job == true
uses: actions/upload-artifact@v4
with:
name: project-version
path: version.txt
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
# Download the build artifacts from the build job
- name: Download Linux binary
uses: actions/download-artifact@v4
with:
name: runlike-linux-amd64
- name: Download MacOS binary
uses: actions/download-artifact@v4
with:
name: runlike-macos-amd64
- name: Download Windows binary
uses: actions/download-artifact@v4
with:
name: runlike-windows-amd64
- name: Download version file
uses: actions/download-artifact@v4
with:
name: project-version
# Read the version from the version file
- name: Read version
id: read_version
run: |
VERSION=$(cat version.txt)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version is $VERSION"
# Create a new GitHub release and upload binaries
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: "v${{ env.VERSION }}"
draft: false
prerelease: false
# Upload the compiled binaries to the created release
- name: Upload Linux binary to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: runlike
asset_name: runlike-linux-amd64
asset_content_type: application/octet-stream
# Upload the compiled binaries to the created release
- name: Upload MacOS binary to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: runlike
asset_name: runlike-macos-amd64
asset_content_type: application/octet-stream
# Upload the compiled binaries to the created release
- name: Upload Windows binary to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: runlike.exe
asset_name: runlike-windows-amd64.exe
asset_content_type: application/octet-stream