Skip to content

Commit

Permalink
Merge pull request #121 from DefGuard/dev
Browse files Browse the repository at this point in the history
merge dev to main
  • Loading branch information
t-aleksander authored Aug 30, 2024
2 parents 6efae0f + c71e8ed commit 5ab9cfc
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 119 deletions.
1 change: 0 additions & 1 deletion .fpm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-s dir
--name defguard-gateway
--architecture x86_64
--description "defguard VPN gateway service"
--url "https://defguard.net/"
--maintainer "teonite"
80 changes: 80 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build Docker image

on:
workflow_call:
inputs:
tags:
description: "List of tags as key-value pair attributes"
required: false
type: string

env:
GHCR_REPO: ghcr.io/defguard/gateway

jobs:
build-docker:
runs-on:
- self-hosted
- Linux
- ${{ matrix.runner }}
strategy:
matrix:
cpu: [arm64, amd64]
include:
- cpu: arm64
runner: ARM64
- cpu: amd64
runner: X64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["dockerhub-proxy.teonite.net"]
- name: Build container
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/${{ matrix.cpu }}
provenance: false
push: true
tags: ${{ env.GHCR_REPO }}:${{ github.sha }}-${{ matrix.cpu }}
cache-from: type=gha
cache-to: type=gha,mode=max

docker-manifest:
runs-on: [self-hosted, Linux]
needs: [build-docker]
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GHCR_REPO }}
tags: ${{ inputs.tags }}
- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifests
run: |
tags='${{ env.GHCR_REPO }}:${{ github.sha }} ${{ steps.meta.outputs.tags }}'
for tag in ${tags}
do
docker manifest create --amend ${tag} ${{ env.GHCR_REPO }}:${{ github.sha }}-amd64 ${{ env.GHCR_REPO }}:${{ github.sha }}-arm64
docker manifest push ${tag}
done
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Debug
run: echo ${{ github.ref_name }}
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache
Expand Down
46 changes: 11 additions & 35 deletions .github/workflows/current.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,15 @@ on:
- "*.md"
- "LICENSE"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-docker:
runs-on: [self-hosted, Linux, X64]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/defguard/gateway
tags: |
type=ref,event=branch
type=raw,value=current
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-current:
uses: ./.github/workflows/build-docker.yml
with:
tags: |
type=raw,value=current
type=ref,event=branch
type=sha
40 changes: 20 additions & 20 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: rustdoc Github Pages
on:
push:
branches:
- main
branches:
- main

env:
CARGO_INCREMENTAL: 0
Expand All @@ -14,27 +14,27 @@ jobs:
rustdoc:
runs-on: [self-hosted, Linux]
container:
image: rust:1.75
image: rust:1

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Rust toolchain
run: rustup update --no-self-update stable
- name: Install Rust toolchain
run: rustup update --no-self-update stable

- name: Install protoc
run: apt-get update && apt-get -y install protobuf-compiler
- name: Install protoc
run: apt-get update && apt-get -y install protobuf-compiler

- name: Build Docs
run: cargo doc --all --no-deps
- name: Build Docs
run: cargo doc --all --no-deps

- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./target/doc
force_orphan: true
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./target/doc
force_orphan: true
70 changes: 17 additions & 53 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,14 @@ concurrency:
cancel-in-progress: true

jobs:
publish-docker:
runs-on: [self-hosted, Linux]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/DefGuard/gateway
tags: |
type=raw,value=latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
with:
config-inline: |
[registry."docker.io"]
mirrors = ["dockerhub-proxy.teonite.net"]
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-latest:
uses: ./.github/workflows/build-docker.yml
with:
tags: |
type=raw,value=latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
create-release:
name: create-release
Expand All @@ -69,28 +34,27 @@ jobs:

build-release:
name: Release ${{ matrix.build }}
needs: ["create-release"]
needs: [create-release]
runs-on:
- self-hosted
- ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: [linux, linux-arm, linux-arm64, freebsd]
build: [linux, linux-arm64, freebsd]
include:
- build: linux
arch: amd64
os: Linux
asset_name: defguard-gateway-linux-x86_64
target: x86_64-unknown-linux-gnu
- build: linux-arm
os: Linux
asset_name: defguard-gateway-linux-armv7
target: armv7-unknown-linux-gnueabihf
- build: linux-arm64
arch: arm64
os: Linux
asset_name: defguard-gateway-linux-arm64
target: aarch64-unknown-linux-gnu
- build: freebsd
arch: amd64
os: Linux
asset_name: defguard-gateway-freebsd-x86_64
target: x86_64-unknown-freebsd
Expand Down Expand Up @@ -147,7 +111,7 @@ jobs:
uses: defGuard/fpm-action@main
with:
fpm_args: "${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/sbin/defguard-gateway defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service example-config.toml=/etc/defguard/gateway.toml"
fpm_opts: "--debug --output-type deb --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb"
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type deb --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb"

- name: Upload DEB
if: matrix.build != 'freebsd'
Expand All @@ -165,7 +129,7 @@ jobs:
uses: defGuard/fpm-action@main
with:
fpm_args: "${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/sbin/defguard-gateway defguard-gateway.service=/usr/lib/systemd/system/defguard-gateway.service example-config.toml=/etc/defguard/gateway.toml"
fpm_opts: "--debug --output-type rpm --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm"
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type rpm --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm"

- name: Upload RPM
if: matrix.build == 'linux'
Expand All @@ -183,7 +147,7 @@ jobs:
uses: defGuard/fpm-action@main
with:
fpm_args: "${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard-gateway example-config.toml=/etc/defguard/gateway.toml defguard-rc.conf=/etc/rc.conf.d/defguard-gateway"
fpm_opts: "--debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg --freebsd-osversion '*'"
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg --freebsd-osversion '*'"

- name: Upload FreeBSD
if: matrix.build == 'freebsd'
Expand All @@ -210,7 +174,7 @@ jobs:
opnsense/src/opnsense/mvc/app/views/OPNsense/DefguardGateway/=usr/local/opnsense/mvc/app/views/OPNsense/DefguardGateway
opnsense/src/opnsense/service/templates/OPNsense/DefguardGateway/=/usr/local/opnsense/service/templates/OPNsense/DefguardGateway
opnsense/src/opnsense/service/conf/actions.d/actions_defguardgateway.conf=/usr/local/opnsense/service/conf/actions.d/actions_defguardgateway.conf"
fpm_opts: "--debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg --freebsd-osversion '*'"
fpm_opts: "--architecture ${{ matrix.arch }} --debug --output-type freebsd --version ${{ env.VERSION }} --package defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg --freebsd-osversion '*'"

- name: Upload OPNsense package
if: matrix.build == 'freebsd'
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "defguard-gateway"
version = "0.7.1"
version = "0.7.2"
edition = "2021"

[dependencies]
Expand All @@ -12,15 +12,15 @@ chrono = { version = "0.4", default-features = false, features = [
"std",
] }
clap = { version = "4.5", features = ["derive", "env"] }
defguard_wireguard_rs = { git = "https://github.com/DefGuard/wireguard-rs.git", rev = "v0.4.6" }
defguard_wireguard_rs = { git = "https://github.com/DefGuard/wireguard-rs.git", rev = "v0.4.7" }
env_logger = "0.11"
gethostname = "0.5"
log = "0.4"
prost = "0.13"
serde = { version = "1.0", features = ["derive"] }
syslog = "7.0"
thiserror = "1.0"
tonic = { version = "0.12", features = ["gzip", "tls", "tls-roots"] }
tonic = { version = "0.12", features = ["gzip", "tls", "tls-native-roots"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tokio-stream = { version = "0.1", features = [] }
toml = { version = "0.8", default-features = false, features = ["parse"] }
Expand Down
Loading

0 comments on commit 5ab9cfc

Please sign in to comment.