Skip to content

Merge pull request #121 from DefGuard/dev #88

Merge pull request #121 from DefGuard/dev

Merge pull request #121 from DefGuard/dev #88

Workflow file for this run

name: Publish
on:
push:
tags:
- v*.*.*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
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
runs-on: self-hosted
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
steps:
- name: Create GitHub release
id: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
generate_release_notes: true
build-release:
name: Release ${{ matrix.build }}
needs: [create-release]
runs-on:
- self-hosted
- ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
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-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
steps:
# Store the version, stripping any v-prefix
- name: Write release version
run: |
VERSION=${GITHUB_REF_NAME#v}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build release binary
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --locked --release --target ${{ matrix.target }}
- name: Rename binary
run: mv target/${{ matrix.target }}/release/defguard-gateway ${{ matrix.asset_name }}-${{ github.ref_name }}
- name: Tar
uses: a7ul/tar-action@v1.1.0
with:
command: c
files: |
${{ matrix.asset_name }}-${{ github.ref_name }}
outPath: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
- name: Upload release archive
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
asset_name: ${{ matrix.asset_name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
asset_content_type: application/octet-stream
- name: Build DEB package
if: matrix.build != 'freebsd'
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: "--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'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb
asset_content_type: application/octet-stream
- name: Build RPM package
if: matrix.build == 'linux'
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: "--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'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm
asset_content_type: application/octet-stream
- name: Build FreeBSD package
if: matrix.build == 'freebsd'
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: "--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'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.pkg
asset_content_type: application/octet-stream
- name: Build OPNsense package
if: matrix.build == 'freebsd'
uses: defGuard/fpm-action@main
with:
fpm_args:
"${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway
defguard-gateway.service.freebsd=/etc/rc.d/defguard-gateway
example-config.toml=/etc/defguard/gateway.toml
defguard-rc.conf=/etc/rc.conf.d/defguard-gateway
opnsense/src/opnsense/mvc/app/controllers/OPNsense/DefguardGateway/=/usr/local/opnsense/mvc/app/controllers/OPNsense/DefguardGateway
opnsense/src/opnsense/mvc/app/models/OPNsense/DefguardGateway/=/usr/local/opnsense/mvc/app/models/OPNsense/DefguardGateway
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: "--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'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
asset_name: defguard-gateway_${{ env.VERSION }}_x86_64-unknown-opnsense.pkg
asset_content_type: application/octet-stream