-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (170 loc) · 5.52 KB
/
nightly.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
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
174
175
176
177
178
179
180
181
182
183
184
185
name: nightly
on:
# schedule:
# - cron: "5 5 * * *"
workflow_dispatch:
# inputs:
# tag_name:
# description: "Tag name for release"
# required: false
# default: nightly
env:
CARGO_TERM_COLOR: always
USE_CROSS: true
FETCH_DEPTH: 0
RELEASE_NAME: "stow-cm"
defaults:
run:
shell: bash
jobs:
build:
runs-on: ${{ matrix.build.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
# build: [linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc]
build: [
{
plat: linux,
os: ubuntu-latest,
rust: stable,
target: x86_64-unknown-linux-musl,
},
{
plat: macos,
os: macos-latest,
rust: stable,
target: x86_64-apple-darwin,
},
# {
# plat: linux-arm,
# os: ubuntu-latest,
# rust: stable,
# target: arm-unknown-linux-gnueabihf
# },
# {
# plat: win-msvc,
# os: windows-latest,
# rust: stable,
# target: x86_64-pc-windows-msvc
# },
# {
# plat: win-gnu,
# os: windows-latest,
# rust: stable-x86_64-gnu,
# target: x86_64-pc-windows-gnu
# },
# {
# plat: win32-msvc,
# os: windows-latest,
# rust: stable,
# target: i686-pc-windows-msvc
# },
]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.build.rust }}
targets: ${{ matrix.build.target }}
- uses: Swatinem/rust-cache@v2
- name: build release binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target=${{ matrix.build.target }}
use-cross: ${{ env.USE_CROSS }}
- name: Strip release binary (linux and macos)
if: matrix.build.plat == 'linux' || matrix.build.plat == 'macos'
run: strip "target/${{ matrix.build.target }}/release/${{ env.RELEASE_NAME }}"
- name: Strip release binary (arm)
if: matrix.build.plat == 'linux-arm'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
rustembedded/cross:arm-unknown-linux-gnueabihf \
arm-linux-gnueabihf-strip \
/target/arm-unknown-linux-gnueabihf/release/${{ env.RELEASE_NAME }}
- name: Build archive
shell: bash
run: |
staging="${{ env.RELEASE_NAME }}-${{ matrix.build.target }}"
mkdir -p "$staging"
mkdir -p "artifacts"
cp {README.md,LICENSE} "$staging/"
if [ "${{ matrix.build.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.build.target }}/release/${{ env.RELEASE_NAME }}.exe" "$staging/"
7z a "artifacts/$staging.zip" "$staging"
sha256sum "artifacts/$staging.zip" > "artifacts/$staging.zip.sha256sum"
else
cp "target/${{ matrix.build.target }}/release/${{ env.RELEASE_NAME }}" "$staging/"
tar czf "artifacts/$staging.tar.gz" "$staging"
shasum -a 256 "artifacts/$staging.tar.gz" > "artifacts/$staging.tar.gz.sha256sum"
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.build.target }}
path: artifacts/*
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: delete exist release
run: gh release delete nightly --cleanup-tag
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
# uses: actions/github-script@v7
# with:
# script: |
# let tagName = "nightly"
# try {
# const { data: { id:release_id } } = await github.rest.repos.getReleaseByTag({
# owner: context.repo.owner,
# repo: context.repo.repo,
# tag: tagName,
# });
# if ( release_id ) {
# await github.rest.repos.deleteRelease({
# owner: context.repo.owner,
# repo: context.repo.repo,
# release_id,
# });
# }
# await github.rest.git.deleteRef({
# owner: context.repo.owner,
# repo: context.repo.repo,
# ref: `tags/${tagName}`,
# });
# } catch (e) {
# console.error(e)
# }
- name: download assets
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: "build Changelog"
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
token: "${{ github.token }}"
mode: "COMMIT"
- name: create nightly release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
append_body: true
body: ${{steps.build_changelog.outputs.changelog}}
tag_name: "nightly"
name: "Release nightly"
target_commitish: "${{ github.sha }}"
prerelease: true
draft: false
fail_on_unmatched_files: false
files: |
artifacts/*