-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Build RPM Package | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: fedora:41 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install build tools and dependencies | ||
run: | | ||
dnf install -y git rpm-build sudo golang | ||
- name: Setup environment | ||
run: | | ||
mkdir -p ${GITHUB_WORKSPACE}/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} | ||
- name: Copy necessary files to the build environment | ||
run: | | ||
cp *.go go.mod version.txt ${GITHUB_WORKSPACE}/rpmbuild/SOURCES/ | ||
cp .pkgs/rpm/SPECS/*.spec ${GITHUB_WORKSPACE}/rpmbuild/SPECS/ | ||
- name: Build the source tarball | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/rpmbuild/SOURCES | ||
tar -czf dotp-$(cat version.txt).tar.gz --transform "s,^,dotp-$(cat version.txt)/," *.go go.mod version.txt | ||
- name: Build RPM Package | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/rpmbuild | ||
rpmbuild -ba \ | ||
--define "_topdir ${GITHUB_WORKSPACE}/rpmbuild" \ | ||
--define "_sourcedir ${GITHUB_WORKSPACE}/rpmbuild/SOURCES" \ | ||
SPECS/*.spec | ||
- name: Setup artifact path | ||
run: | | ||
rpm_path=$(find ${GITHUB_WORKSPACE}/rpmbuild/RPMS -type f -name "*.rpm" | head -n1) | ||
echo "RPM_PATH=$rpm_path" >> $GITHUB_ENV | ||
echo "RPM_NAME=$(basename $rpm_path)" >> $GITHUB_ENV | ||
- name: Upload RPM to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ${{ env.RPM_PATH }} | ||
asset_name: ${{ env.RPM_NAME }} | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
- name: Upload RPM Package | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: rpm-packages | ||
path: /home/builder/rpmbuild/RPMS/x86_64/*.rpm | ||
permissions: | ||
contents: write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM fedora:41 AS builder | ||
|
||
RUN dnf install -y git rpm-build sudo golang | ||
|
||
RUN useradd -m builder && \ | ||
echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
WORKDIR /home/builder | ||
|
||
RUN mkdir -p /home/builder/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} && \ | ||
chown -R builder:builder /home/builder | ||
|
||
USER builder | ||
|
||
COPY *.go go.mod version.txt /home/builder/rpmbuild/SOURCES/ | ||
COPY .pkgs/rpm/SPECS/*.spec /home/builder/rpmbuild/SPECS/ | ||
|
||
WORKDIR /home/builder/rpmbuild/SOURCES | ||
|
||
RUN tar -czf dotp-$(cat version.txt).tar.gz \ | ||
--transform "s,^,dotp-$(cat version.txt)/," \ | ||
*.go go.mod version.txt | ||
|
||
WORKDIR /home/builder/rpmbuild | ||
|
||
RUN rpmbuild -ba SPECS/*.spec | ||
|
||
FROM scratch | ||
WORKDIR /pkg | ||
COPY --from=builder /home/builder/rpmbuild/RPMS/x86_64/*.rpm . | ||
ENTRYPOINT ["dotp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Name: dotp | ||
Version: 0.0.1.20240712.02 | ||
Release: 1%{?dist} | ||
Summary: Command-line tool for managing Time-based One-Time Passwords (TOTPs) | ||
|
||
License: GPL-3.0-or-later | ||
URL: https://github.com/petlack/dotp | ||
Source: %{name}-%{version}.tar.gz | ||
|
||
BuildRequires: go | ||
|
||
%global debug_package %{nil} # Disable automatic debuginfo package generation | ||
|
||
%description | ||
%{summary} | ||
|
||
%prep | ||
%autosetup -n %{name}-%{version} | ||
|
||
%build | ||
export GOOS=linux | ||
go version | ||
go build -a -ldflags="-linkmode=external" -o build/%{name} . | ||
|
||
%install | ||
install -Dm755 build/%{name} %{buildroot}%{_bindir}/%{name} | ||
|
||
%check | ||
go test ./... | ||
|
||
%files | ||
%{_bindir}/%{name} | ||
|
||
%changelog | ||
* Fri Jul 12 2024 John Doe <email@example.com> - %{version}-%{release} | ||
- Initial RPM release |