-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (115 loc) · 4.28 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
# Copyright 2021 Agnostiq Inc.
#
# This file is part of Covalent.
#
# Licensed under the GNU Affero General Public License 3.0 (the "License").
# A copy of the License may be obtained with this software package or at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Use of this file is prohibited except in compliance with the License. Any
# modifications or derivative works of this file must retain this copyright
# notice, and modified files must contain a notice indicating that they have
# been altered from the originals.
#
# Covalent is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
#
# Relief from the License may be granted by purchasing a commercial license.
# Copyright 2022 Will Cunningham
#
# This file is part of FastMath.
#
# Modifications:
# - The OpsBot user and token is changed to reference FastMath instead of
# Covalent.
# - Added buildrpm job
name: release
on:
push:
branches:
- master
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Check out master
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Read version
run: |
VERSION="$(cat ./VERSION)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "RELEASE=v$VERSION" >> $GITHUB_ENV
- name: Tag commit
id: push
run: |
git config user.name "FastMathOpsBot"
git config user.email "fastmathopsbot@users.noreply.github.com"
git tag -a $RELEASE -m "Release $RELEASE"
git remote set-url origin https://${{ secrets.FASTMATH_OPS_BOT_TOKEN }}@github.com/wjcunningham7/fastmath.git
git push origin $RELEASE
- name: Generate release message
id: message
run: |
begin=$(grep -n "\b${VERSION}\b" ./CHANGELOG.md | cut -d ':' -f 1)
previous_version=$(git describe --abbrev=0 $RELEASE^ | cut -c2-)
end=$(tail -n +$((begin+1)) ./CHANGELOG.md | grep -n -m 1 "\b${previous_version}\b" | cut -d ':' -f 1)
echo 'MESSAGE<<EOF' >> $GITHUB_ENV
tail +$begin ./CHANGELOG.md | head -$end >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create release
id: create_release
if: ${{ steps.push.outcome == 'success' && steps.message.outcome == 'success' }}
uses: ncipollo/release-action@v1
with:
body: ${{ env.MESSAGE }}
token: ${{ secrets.FASTMATH_OPS_BOT_TOKEN }}
tag: ${{ env.RELEASE }}
prerelease: true
buildrpm:
name: Build RPM Package
needs: release
runs-on: ubuntu-latest
container: centos:centos7
steps:
- name: Check out head
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install build tools
run: yum install -y make rpm-build automake autoconf gsl-devel boost
- name: Read version
run: |
VERSION=`cat VERSION`
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build tarball
run: |
mkdir -p $HOME/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir fastmath-$VERSION
cp -r include configure.ac LICENSE Makefile.am VERSION fastmath-$VERSION
tar cvzf fastmath-$VERSION.tar.gz fastmath-$VERSION
mv fastmath-$VERSION.tar.gz $HOME/rpmbuild/SOURCES
- name: Generate spec
run: |
bash ./pkg/build-rpm-spec.sh
mv pkg/fastmath.spec $HOME/rpmbuild/SPECS
- name: Build RPM
run: rpmbuild -ba $HOME/rpmbuild/SPECS/fastmath.spec
- name: Test RPM installation
run: rpm -ivvh $HOME/rpmbuild/RPMS/x86_64/fastmath-$VERSION-1.x86_64.rpm
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_name: fastmath-${{ env.VERSION }}-1.x86_64.rpm
asset_path: /github/home/rpmbuild/RPMS/fastmath-${{ env.VERSION }}-1.x86_64.rpm
asset_content_type: application/x-rpm