Skip to content

Update build-and-package.yml #22

Update build-and-package.yml

Update build-and-package.yml #22

name: Build and Package
on:
push:
tags:
- 'v*'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set Version without Leading 'v'
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Set up CMake
uses: lukka/get-cmake@latest
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential cmake devscripts libconfig-dev libevent-dev
- name: Configure with CMake
run: cmake -B build -S .
- name: Build with CMake
run: cmake --build build
- name: Package to DEB
run: |
mkdir -p debian/DEBIAN
mkdir -p debian/usr/local/bin
cp build/obftun debian/usr/local/bin/
# Copy service and config files
mkdir -p debian/etc/systemd/system
cp contrib/obftun.service debian/etc/systemd/system/
cp contrib/obftun.conf debian/etc/
# Control file for deb packaging
cat <<EOF > debian/DEBIAN/control
Package: obftun
Version: ${VERSION}
Section: Network
Priority: optional
Architecture: amd64
Depends: libc6 (>= 2.7)
Maintainer: psylity <psylity@gmail.com>
Description: obftun - yet another obfuscated tunnel
EOF
dpkg-deb --build debian obftun.deb
- name: Package to RPM
run: |
mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p rpm/BUILDROOT/usr/local/bin
mkdir -p rpm/BUILDROOT/etc/systemd/system
mkdir -p rpm/BUILDROOT/usr/local/bin/
cp build/obftun rpm/BUILDROOT/usr/local/bin/
cp contrib/obftun.service rpm/BUILDROOT/etc/systemd/system/
cp contrib/obftun.conf rpm/BUILDROOT/etc/
cat <<EOF > rpm/SPECS/obftun.spec
Name: obftun
Version: ${VERSION}
Release: 1%{?dist}
Summary: yet another obfuscated tunnel
License: MIT
BuildArch: x86_64
Requires: glibc
%description
obftun - yet another obfuscated tunnel
%install
mkdir -p %{buildroot}/usr/local/bin
mkdir -p %{buildroot}/etc/systemd/system
cp -a %{_topdir}/BUILDROOT/etc/systemd/system/obftun.service %{buildroot}/etc/systemd/system/
cp -a %{_topdir}/BUILDROOT/etc/obftun.conf %{buildroot}/etc/
cp -a %{_topdir}/BUILDROOT/usr/local/bin/obftun %{buildroot}/usr/local/bin/
%files
/usr/local/bin/obftun
/etc/systemd/system/obftun.service
/etc/obftun.conf
%changelog
EOF
rpmbuild --define "_topdir $(pwd)/rpm" -bb rpm/SPECS/obftun.spec
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload DEB to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: obftun.deb
asset_name: obftun-${{ env.VERSION }}.deb
asset_content_type: application/vnd.debian.binary-package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload RPM to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: rpm/RPMS/x86_64/obftun-${{ env.VERSION }}-1.x86_64.rpm
asset_name: obftun-${{ env.VERSION }}.rpm
asset_content_type: application/x-rpm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}