Skip to content

Commit 123c3b5

Browse files
committed
update gh workflow, update default yaml config
1 parent 890035e commit 123c3b5

5 files changed

Lines changed: 71 additions & 96 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deployment
33
on:
44
push:
55
tags:
6-
- v*
6+
- "v*"
77

88
jobs:
99
test:
@@ -15,82 +15,104 @@ jobs:
1515
needs: test
1616
env:
1717
ARTIFACT_DIR: artifact
18+
BINARY_NAME: baru-linux-x86_64
1819
outputs:
1920
sha256: ${{ steps.gen_sha256.outputs.sha256 }}
2021
steps:
2122
- name: Checkout
22-
uses: actions/checkout@v5
23+
uses: actions/checkout@v6
24+
2325
- name: Install Rust toolchain
2426
uses: dtolnay/rust-toolchain@stable
27+
2528
- name: Install dependencies
2629
run: sudo apt-get install libnl-3-dev libnl-genl-3-dev libnl-route-3-dev libpulse-dev
30+
2731
- name: Build
2832
run: cargo build --release --locked
33+
2934
- name: Prepare artifact
3035
run: |
31-
mkdir $ARTIFACT_DIR
32-
mv -f target/release/baru $ARTIFACT_DIR/
33-
- name: Gen sha256
34-
id: gen_sha256
35-
working-directory: ${{ env.ARTIFACT_DIR }}
36+
mkdir ${{ env.ARTIFACT_DIR }}
37+
mv -f target/release/baru ${{ env.ARTIFACT_DIR }}/${{ env.BINARY_NAME }}
38+
cd ${{ env.ARTIFACT_DIR }}
39+
sha256sum ${{ env.BINARY_NAME }} > ${{ env.BINARY_NAME }}.sha256sum
40+
ls -lh
41+
42+
- name: Print build info
3643
run: |
37-
sha256=$(sha256sum baru)
38-
echo "$sha256"
39-
echo "sha256=$sha256" >> "$GITHUB_OUTPUT"
40-
echo "$sha256" > baru.sha256sum
44+
echo "--------------------------------------------"
45+
echo "binary name: ${{ env.BINARY_NAME }}"
46+
echo "sha256sum: $(cat ${{ env.ARTIFACT_DIR }}/${{ env.BINARY_NAME }}.sha256sum)"
47+
echo "file size: $(du -h ${{ env.ARTIFACT_DIR }}/${{ env.BINARY_NAME }} | cut -f1)"
48+
echo "--------------------------------------------"
49+
4150
- name: Upload artifact
42-
uses: actions/upload-artifact@v4
51+
uses: actions/upload-artifact@v6
4352
with:
44-
name: baru
53+
name: baru-linux-x86_64
4554
path: ${{ env.ARTIFACT_DIR }}
46-
retention-days: 2
55+
retention-days: 7
56+
if-no-files-found: error
4757

4858
release:
49-
name: Release
59+
name: Create GitHub Release
5060
needs: build
5161
runs-on: ubuntu-latest
5262
permissions:
5363
contents: write
54-
env:
55-
SHA256: ${{ needs.build.outputs.sha256 }}
5664
steps:
5765
- name: Download binary artifact
58-
uses: actions/download-artifact@v5
66+
uses: actions/download-artifact@v6
5967
with:
60-
name: baru
61-
- name: Integrity check
62-
run: |
63-
sha256sum -c baru.sha256sum
64-
[ "$SHA256" == "$(cat baru.sha256sum)" ] && echo "sha256 OK"
68+
name: baru-linux-x86_64
69+
path: artifacts
70+
6571
- name: Create release
6672
uses: softprops/action-gh-release@v2
6773
with:
74+
name: ${{ github.ref_name }}
6875
files: |
69-
baru
70-
baru.sha256sum
76+
artifacts/*
7177
7278
aur-packaging:
7379
name: Publish AUR package
7480
needs: release
7581
runs-on: ubuntu-latest
7682
env:
77-
PKGNAME: baru
78-
PKGBUILD: ./.pkg/aur/PKGBUILD
79-
RELEASE_TAG: ${{ github.ref_name }}
80-
REPOSITORY: ${{ github.repository }}
83+
PKGBUILD: ./.pkg/arch/PKGBUILD
8184
steps:
8285
- name: Checkout
83-
uses: actions/checkout@v5
84-
- name: Download sources
85-
run: curl -LfsSo "$PKGNAME-$RELEASE_TAG".tar.gz "https://github.com/$REPOSITORY/archive/refs/tags/$RELEASE_TAG.tar.gz"
86+
uses: actions/checkout@v6
87+
88+
- name: Get tarball sha256sum
89+
id: tarball
90+
run: |
91+
curl -LfsSo sources.tar.gz "https://github.com/doums/baru/archive/refs/tags/${{ github.ref_name }}.tar.gz"
92+
sha256sum=$(sha256sum sources.tar.gz | awk '{print $1}')
93+
echo "tarball sha256sum: $sha256sum"
94+
echo "sha256sum=$sha256sum" >> "$GITHUB_OUTPUT"
95+
8696
- name: Update PKGBUILD
87-
run: ./.pkg/aur/update.sh
88-
- name: Show PKGBUILD
89-
run: cat "$PKGBUILD"
97+
env:
98+
RELEASE_TAG: ${{ github.ref_name }}
99+
SHA256SUM: ${{ steps.tarball.outputs.sha256sum }}
100+
run: |
101+
# strip v prefix
102+
version="${RELEASE_TAG#v}"
103+
# ⚠ Dashes are not allowed in package version, replace any - by _
104+
pkgver=${version//-/_}
105+
echo "pkgver: $pkgver"
106+
# update version and sha256sum
107+
sed -i "s/pkgver=.*/pkgver=$pkgver/" ${{ env.PKGBUILD }}
108+
sed -i "s/sha256sums=(.*)/sha256sums=('$SHA256SUM')/" ${{ env.PKGBUILD }}
109+
echo "--------------------------------------------"
110+
cat ${{ env.PKGBUILD }}
111+
90112
- name: Publish
91-
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
113+
uses: KSXGitHub/github-actions-deploy-aur@v4.1.2
92114
with:
93-
pkgname: ${{ env.PKGNAME }}
115+
pkgname: baru
94116
pkgbuild: ${{ env.PKGBUILD }}
95117
commit_username: ${{ secrets.AUR_USERNAME }}
96118
commit_email: ${{ secrets.AUR_EMAIL }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v5
19+
uses: actions/checkout@v6
2020
- name: Install Rust toolchain
2121
uses: dtolnay/rust-toolchain@stable
2222
with:
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ conflicts=('baru')
1414
options=(!debug)
1515
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
1616
sha256sums=('xxx')
17+
_pkgdir="$pkgname-$pkgver"
1718

1819
build() {
19-
cd "$pkgname-$pkgver"
20+
cd "$srcdir/$_pkgdir"
2021
cargo build --release --locked
2122
}
2223

2324
package() {
24-
cd "$pkgname-$pkgver"
25-
install -Dvm 755 "target/release/baru" "$pkgdir/usr/bin/baru"
26-
install -Dvm 644 "baru.yaml" "$pkgdir/usr/share/baru/baru.yaml"
25+
cd "$srcdir/$_pkgdir"
26+
install -Dvm 755 "$srcdir/target/release/baru" "$pkgdir/usr/bin/baru"
27+
install -Dvm 644 "$srcdir/$_pkgdir/baru.yaml" "$pkgdir/usr/share/baru/baru.yaml"
2728
}
2829

.pkg/aur/update.sh

Lines changed: 0 additions & 54 deletions
This file was deleted.

baru.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ battery:
113113
#
114114
discharging_label: bat
115115

116+
# not_charging_label: String, default: 'bat
117+
#
118+
# The label printed when the battery is in "Not charging" state.
119+
#
120+
not_charging_label: "'bat"
121+
116122
# low_label: String, default: !ba
117123
#
118124
# The label printed when the battery is discharging and the level is low.

0 commit comments

Comments
 (0)