Skip to content

Commit

Permalink
NOJ - Debian package release hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
gr211 committed Jun 20, 2024
1 parent b255b0e commit 09dfb54
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
goos: [linux]
goarch: [amd64]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Build
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build
86 changes: 83 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ name: Go Release

on:
push:
branches:
- main
tags:
- 'v*.*.*' # Matches v1.0.0, v2.1.3, etc.
- 'latest'

jobs:
build:
Expand All @@ -29,6 +26,8 @@ jobs:
- name: Build
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o gohip-${{ matrix.goos }}-${{ matrix.goarch }}
RELEASE_VERSION=$(echo ${{ github.ref }} | tr -d 'refs/tags/v')
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Create Release
id: create_release
Expand All @@ -50,3 +49,84 @@ jobs:
asset_name: gohip-linux-amd64
asset_path: ./gohip-linux-amd64
asset_content_type: application/octet-stream

- name: Create Debian package
env:
DESTDIR: '/tmp/gohip-deb' # keep path absolute - meson has issues with relative paths on CI
run: |
mkdir -p $DESTDIR
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} RELEASE_VERSION=$RELEASE_VERSION DESTDIR=$DESTDIR make debian-pkg
- name: Upload Debian release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
gohip-*-x86_64.deb
gohip-*-x86_64.deb.md5sum
centos:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: System dependencies
run: |
sudo apt-get update
sudo apt-get install -y sudo make alien
RELEASE_VERSION=$(echo ${{ github.ref }} | tr -d 'refs/tags/v')
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Create CentOS 8 package
run: |
wget https://github.com/grumlimited/gohip/releases/download/v$RELEASE_VERSION/gohip-$RELEASE_VERSION-x86_64.deb -O gohip-$RELEASE_VERSION-x86_64.deb
alien -r -k --scripts --target=x86_64 gohip-$RELEASE_VERSION-x86_64.deb
md5sum gohip-$RELEASE_VERSION-1.x86_64.rpm >> gohip-$RELEASE_VERSION-1.x86_64.rpm
- name: Upload CentOS 8 release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
gohip-*-1.x86_64.rpm
gohip-*-1.x86_64.rpm.md5sum
arch:
runs-on: ubuntu-latest
needs: [ build ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare arch package metadata
run: |
RELEASE_VERSION=$(echo ${{ github.ref }} | tr -d 'refs/tags/v')
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
wget https://github.com/grumlimited/gohip/releases/download/v$RELEASE_VERSION/gohip-$RELEASE_VERSION-x86_64.deb -O build-aux/arch/gohip-bin/gohip-$RELEASE_VERSION-x86_64.deb
MD5_SUM=$(md5sum build-aux/arch/gohip-bin/gohip-$RELEASE_VERSION-x86_64.deb | awk '{print $1}')
awk -v q="'" -v MD5_SUM=$MD5_SUM -i inplace 'BEGINFILE{print "md5sums=(" q MD5_SUM q ")"}{print}' build-aux/arch/gohip-bin/PKGBUILD
awk -v RELEASE_VERSION=$RELEASE_VERSION -i inplace 'BEGINFILE{print "pkgver=" q RELEASE_VERSION q ""}{print}' build-aux/arch/gohip-bin/PKGBUILD
- name: Validate PKGBUILD
id: validate-pkgbuild
uses: 2m/arch-pkgbuild-builder@v1.16
with:
debug: true
target: pkgbuild
pkgname: build-aux/arch/gohip-bin/

- name: Create arch package checksum file
run: |
sudo chown -R $USER .
md5sum build-aux/arch/gohip-bin/gohip-bin-$RELEASE_VERSION-1-x86_64.pkg.tar.zst >> build-aux/arch/gohip-bin/gohip-bin-$RELEASE_VERSION-1-x86_64.pkg.tar.zst.md5sum
- name: Upload Arch Linux release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
build-aux/arch/gohip-bin/gohip-bin-*-1-x86_64.pkg.tar.zst
build-aux/arch/gohip-bin/gohip-bin-*-1-x86_64.pkg.tar.zst.md5sum
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
result
gohip
command.log
.idea
*.iml
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@ push_tag:
@git push --force origin latest

.PHONY: all delete_latest_tag recreate_tag push_tag

build:
go build -o gohip-$(GOOS)-$(GOARCH)

install: build
mkdir -p $(DESTDIR)/usr/bin
cp gohip-$(GOOS)-$(GOARCH) $(DESTDIR)/usr/bin/gohip

debian-pkg: install
mkdir -p $(DESTDIR)/DEBIAN
cp build-aux/debian/control $(DESTDIR)/DEBIAN/
echo "Version: $(RELEASE_VERSION)" >> $(DESTDIR)/DEBIAN/control
cp build-aux/debian/postinst $(DESTDIR)/DEBIAN/
chmod 775 $(DESTDIR)/DEBIAN/postinst
dpkg-deb --build $(DESTDIR) gohip-$(RELEASE_VERSION)-x86_64.deb
md5sum gohip-$(RELEASE_VERSION)-x86_64.deb > gohip-$(RELEASE_VERSION)-x86_64.deb.md5sum
28 changes: 28 additions & 0 deletions build-aux/arch/gohip-bin/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
_packager="Romain Gallet <romain_gallet_at_gmail_com"
_deb_pkgname=gohip
pkgname=gohip-bin
pkgrel=1
pkgdesc='gohip global protect vpn HIP script.'
arch=('x86_64')
url="https://github.com/grumlimited/$_deb_pkgname"
license=('GPLv3')
groups=()
depends=('iproute2')
makedepends=()
checkdepends=()
optdepends=()
provides=()
replaces=()
backup=()
options=()
source=("$url/releases/download/$pkgver/$_deb_pkgname-$pkgver-$arch.deb")
noextract=()

build() {
rm control.tar.zst
tar xvf data.tar.zst
}

package() {
cp -fr usr/ ${pkgdir}
}
7 changes: 7 additions & 0 deletions build-aux/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Package: gohip
Section: network
Priority: optional
Architecture: amd64
Depends: iproute2
Maintainer: romain_gallet_at_gmail_com
Description: gohip global protect vpn HIP script
5 changes: 5 additions & 0 deletions build-aux/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

chmod +x /usr/bin/gohip

exit 0
3 changes: 3 additions & 0 deletions command.log
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@
2024/06/17 21:31:49 Command: ./gohip-v0.2.8 Arguments:
2024/06/17 21:31:52 Command: ./gohip-v0.2.8 Arguments:
2024/06/17 21:31:54 Command: /tmp/go-build2899599716/b001/exe/main Arguments:
2024/06/20 13:11:29 Command: ./gohip Arguments:
2024/06/20 13:23:17 Command: gohip Arguments:
2024/06/20 13:32:04 Command: gohip Arguments:

0 comments on commit 09dfb54

Please sign in to comment.