This repository has been archived by the owner on Apr 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
148 lines (129 loc) · 4.27 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
148
---
on:
push:
# Uncomment to test against a branch
#branches:
# - ci
tags:
- 'v*'
jobs:
create_release:
name: Create GitHub release
runs-on: ubuntu-22.04
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version from tag
id: get_version
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
version=${GITHUB_REF#refs/tags/v}
else
version=0.0.0.${GITHUB_REF#refs/heads/}
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
- name: Create release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Version ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
build:
name: Build project
needs: create_release
runs-on: ubuntu-22.04
env:
CARGO_TERM_COLOR: always
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Rust LLVM target triple
id: get_target
shell: bash
run: |
echo -n 'name=' >> "${GITHUB_OUTPUT}"
RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json \
| jq -r '."llvm-target"' \
>> "${GITHUB_OUTPUT}"
- name: Install clippy
run: rustup component add clippy
- name: Install system dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install clang libfreeipmi-dev libipmimonitoring-dev pkg-config
- name: Run clippy checks in release mode
env:
RUST_BACKTRACE: 1
run: |
cargo clippy --release -- -D warnings
- name: Build in release mode
run: cargo build --release --verbose
build_source_packages:
name: Build source packages
needs:
- create_release
# Intentionally make this sequential, so we don't publish a release to OBS
# that doesn't build
- build
runs-on: ubuntu-22.04
env:
CARGO_TERM_COLOR: always
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build all source packages
env:
VERSION_OVERRIDE: ${{ needs.create_release.outputs.version }}
run: |
sudo apt-get -y update
sudo apt-get -y install cargo debhelper devscripts dh-exec
./dist/build_source_package.py -a
- name: Find vendored tarball
run: |
tarball=(dist/output/tarball/*.vendored.tar.*)
echo "TARBALL_PATH=${tarball}" >> "${GITHUB_ENV}"
echo "TARBALL_NAME=${tarball##*/}" >> "${GITHUB_ENV}"
- name: Upload vendored tarball
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ${{ env.TARBALL_NAME }}
asset_path: ${{ env.TARBALL_PATH }}
asset_content_type: application/octet-stream
- name: Install osc
run: |
sudo apt-get -y update
sudo apt-get -y install libarchive-tools osc python3-m2crypto
- name: Publish source packages to OBS
env:
OSC_CONFIG: ${{ secrets.osc }}
VERSION: ${{ needs.create_release.outputs.version }}
run: |
shopt -s extglob
if [[ "${VERSION}" == 0.0.0.* ]]; then
project=home:chenxiaolong-bot:test
else
project=home:chenxiaolong:ipmi-fan-control
fi
cd dist/output
echo "${OSC_CONFIG}" > oscrc
osc -c oscrc co "${project}"
cd "${project}/ipmi-fan-control"
find -mindepth 1 -maxdepth 1 -type f -delete
bsdtar -xf ../../srpm/*.src.rpm
cp ../../pkgbuild/* .
cp ../../debian/!(*_source.*) .
sha512sum *
osc -c ../../oscrc addremove
osc -c ../../oscrc commit -m "GitHub Actions automated import of version ${VERSION}"