-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (120 loc) · 4.84 KB
/
release.yml
File metadata and controls
144 lines (120 loc) · 4.84 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
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
name: Release
run-name: Release ${{ github.ref_name }}
on:
push:
tags:
- 'v\d+\.\d+'
- 'v\d+\.\d+-\d+'
permissions:
contents: write
jobs:
copr_build:
name: Build on copr
runs-on: ubuntu-latest
container: fedora:latest
steps:
- name: Install copr-cli and git
run: dnf install -y copr-cli git && dnf upgrade -y copr-cli git
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Confirm version and release in spec file
run: |
version="$(awk '/Version:/ {print $2}' cpp-json.spec)"
release="$(awk '/Release:/ {print $2}' cpp-json.spec)"
release="${release%\%\{\?dist\}}"
if [[ ${{ github.ref_name }} =~ - ]]; then
if [[ ${{ github.ref_name }} != "v$version-$release" ]]; then
echo "Tag name does not match version and release in cpp-json.spec"
exit 1
fi
else
if [[ ${{ github.ref_name }} != "v$version" || "$release" != "1" ]]; then
echo "Tag name does not match version in cpp-json.spec"
exit 1
fi
fi
- name: Setup copr-cli
run: |
mkdir -p ~/.config
echo "[copr-cli]" > ~/.config/copr
echo "login = ${{ secrets.COPR_LOGIN }}" >> ~/.config/copr
echo "username = tokox" >> ~/.config/copr
echo "token = ${{ secrets.COPR_TOKEN }}" >> ~/.config/copr
echo "copr_url = https://copr.fedorainfracloud.org" >> ~/.config/copr
- name: Build package
run: |
url="${{ github.repositoryUrl }}"
if [[ $url == git://* ]]; then
url="https://${url:6}"
fi
copr-cli buildscm --clone-url "$url" --commit "${{ github.ref_name }}" ${{ github.repository }} --timeout 1800
make_release:
name: Make release
runs-on: ubuntu-latest
container: fedora:latest
needs: [copr_build]
steps:
- name: Install git
run: dnf install -y git && dnf upgrade -y git
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Get previous tag
id: get_previous_tag
uses: pozetroninc/github-action-get-latest-release@v0.7.0
with:
repository: ${{ github.repository }}
token: ${{ github.token }}
- name: Move vlatest
uses: rickstaa/action-create-tag@v1.7.2
with:
tag: vlatest
force_push_tag: true
commit_sha: ${{ github.sha }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Create changelog
run: |
echo "**Changelog**" > changelog.md
sed -n '/%changelog/,$p' cpp-json.spec | tail -n +2 | awk '/\*/{if (found++ == 1) exit} 1' >> changelog.md
echo "**Full Changelog**: https://github.com/tokox/cpp-json/compare/${{ steps.get_previous_tag.outputs.release }}...${{ github.ref_name }}" >> changelog.md
- name: Create release
uses: ncipollo/release-action@v1.14.0
with:
name: ${{ contains(github.ref_name, '-') && 'Patch' || 'Release'}} ${{ github.ref_name }}
bodyFile: changelog.md
tag: ${{ github.ref_name }}
upload_assets:
name: Upload assets
runs-on: ubuntu-latest
container: fedora:latest
needs: [make_release, copr_build]
steps:
- name: Install copr-cli
run: dnf install -y copr-cli && dnf upgrade -y copr-cli
- name: Setup copr-cli
run: |
mkdir -p ~/.config
echo "[copr-cli]" > ~/.config/copr
echo "login = ${{ secrets.COPR_LOGIN }}" >> ~/.config/copr
echo "username = tokox" >> ~/.config/copr
echo "token = ${{ secrets.COPR_TOKEN }}" >> ~/.config/copr
echo "copr_url = https://copr.fedorainfracloud.org" >> ~/.config/copr
- name: Get copr build id
id: get_copr_build_id
run: echo "id=$(copr-cli list-builds --output-format text-row tokox/cpp-json | grep 'tokox-cpp-json' | grep 'succeeded' | awk '{print $1; exit}')" >> $GITHUB_OUTPUT
- name: Download assets
run: copr-cli download-build --dest assets --rpms ${{ steps.get_copr_build_id.outputs.id }}
- name: Rename assets
run: |
for file in assets/*/*.rpm; do
mv $file assets/$(basename $(dirname $file | sed 's/-x86_64$//'))_$(basename $file)
done
- name: Upload assets
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: assets/*.rpm
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
tag: ${{ github.ref_name }}