-
Notifications
You must be signed in to change notification settings - Fork 8
145 lines (143 loc) · 4.51 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
name: Build & Release
on:
workflow_dispatch:
pull_request:
paths-ignore:
- "**.md"
- .gitignore
- "docs/**"
- "theme/**"
- "po/**"
- book.toml
- .github/workflows/docs.yaml
push:
branches:
- main
paths-ignore:
- "**.md"
- .gitignore
- "docs/**"
- "theme/**"
- "po/**"
- book.toml
- .github/workflows/docs.yaml
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
distro: ${{ steps.distro_check.outputs.distro }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: pre-commit check
run: |
pip install pre-commit
if ! pre-commit run --all-files --show-diff-on-failure
then
echo ''
echo '=== Code style issue detected! ==='
echo 'Suggest changes are listed above.'
echo 'Please install pre-commit and run `pre-commit run --all-files` to fix it.'
echo 'Strongly recommended to run `pre-commit install` to catch issues before pushing.'
echo 'You can learn more abour pre-commit from https://pre-commit.com/'
exit 1
fi
- name: Test
run: |
sudo apt-get update
sudo apt-get build-dep --no-install-recommends -y .
sudo apt-get install --no-install-recommends -y git-buildpackage
export DEBEMAIL="[email protected]"
export DEBFULLNAME='"Radxa Computer Co., Ltd"'
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git branch -m GITHUB_RUNNER || true
git branch -D main || true
git switch -c main || true
make dch
make test all deb
git reset --hard HEAD~1
- name: Build
run: |
make all deb
- name: Workaround actions/upload-artifact#176
run: |
echo "artifacts_path=$(realpath ..)" >> $GITHUB_ENV
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: |
${{ env.artifacts_path }}/*.deb
- name: Check if the latest version is releasable
id: distro_check
run: |
version="$(dpkg-parsechangelog -S Version)"
version="${version//\~/.}"
if [[ -n "$(git tag -l "$version")" ]]
then
echo "distro=UNRELEASED" >> "$GITHUB_OUTPUT"
else
echo "distro=$(dpkg-parsechangelog -S Distribution)" >> "$GITHUB_OUTPUT"
fi
release:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name != 'pull_request' && needs.build.outputs.distro != 'UNRELEASED' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: .artifacts
- name: Prepare for release
run: |
version="$(dpkg-parsechangelog -S Version)"
version="${version//\~/.}"
echo "version=$version" >> $GITHUB_ENV
echo "changes<<EOF" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "$(dpkg-parsechangelog -S Changes)" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "$version" > VERSION
if [[ -f pkg.conf.template ]]
then
sed "s/VERSION/$version/g" pkg.conf.template > pkg.conf
fi
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.version }}
body_path: README.md
token: ${{ secrets.GITHUB_TOKEN }}
target_commitish: ${{ github.ref_name }}
draft: false
prerelease: false
fail_on_unmatched_files: false
files: |
.artifacts/**/*.deb
pkg.conf
VERSION
- name: Append changelog
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.version }}
body: |
## Changelog for ${{ env.version }}
${{ env.changes }}
append_body: true
- name: Update Test repos
uses: radxa-repo/update-repo-action@main
with:
test-repo: true
token: ${{ secrets.RADXA_APT_TEST_REPO_TOKEN }}