bump version (#47) #65
Workflow file for this run
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
name: Publish | |
on: | |
push: | |
tags: | |
- v*.*.* | |
jobs: | |
publish-docker: | |
runs-on: self-hosted | |
steps: | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/DefGuard/gateway | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=raw,value=latest | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build container | |
uses: docker/build-push-action@v3 | |
with: | |
# platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
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 | |
with: | |
generate_release_notes: true | |
build-release: | |
name: Release ${{ matrix.build }} | |
needs: ['create-release'] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
build: [linux, linux-arm, freebsd, opnsense] | |
include: | |
- build: linux | |
os: self-hosted | |
asset_name: defguard-gateway-linux-x86_64 | |
target: x86_64-unknown-linux-gnu | |
- build: linux-arm | |
os: self-hosted | |
asset_name: defguard-gateway-linux-armv7 | |
target: armv7-unknown-linux-gnueabihf | |
- build: freebsd | |
os: self-hosted | |
asset_name: defguard-gateway-freebsd-x86_64 | |
target: x86_64-unknown-freebsd | |
- build: opnsense | |
os: self-hosted | |
asset_name: defguard-gateway-opnsense-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: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build release binary | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Rename binary | |
run: mv target/${{ matrix.target }}/release/defguard-gateway ${{ matrix.asset_name }}-${{ github.ref_name }} | |
- name: Strip release binary (linux) | |
if: matrix.build == 'linux' | |
run: strip "${{ matrix.asset_name }}-${{ github.ref_name }}" | |
- name: Tar | |
uses: a7ul/[email protected] | |
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/[email protected] | |
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 | |
uses: bpicode/github-action-fpm@master | |
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 -t deb --version=${{ env.VERSION }} -p defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.deb" | |
- name: Upload DEB | |
uses: actions/[email protected] | |
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: bpicode/github-action-fpm@master | |
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 -t rpm --version=${{ env.VERSION }} -p defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.rpm" | |
- name: Upload RPM | |
if: matrix.build == 'linux' | |
uses: actions/[email protected] | |
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: bpicode/github-action-fpm@master | |
with: | |
fpm_args: "${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway defguard-gateway.service.freebsd=/usr/local/etc/rc.d/defguard example-config.toml=/etc/defguard/gateway.toml defguard-rc.conf=/etc/rc.conf.d/defguard" | |
fpm_opts: "--debug -t freebsd --version=${{ env.VERSION }} -p defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.txz" | |
- name: Upload freebsd | |
if: matrix.build == 'freebsd' | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.txz | |
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.txz | |
asset_content_type: application/octet-stream | |
- name: Build OPNsense package | |
if: matrix.build == 'opnsense' | |
uses: bpicode/github-action-fpm@master | |
with: | |
fpm_args: | | |
"${{ matrix.asset_name }}-${{ github.ref_name }}=/usr/local/sbin/defguard-gateway | |
defguard-gateway.service.freebsd=/etc/rc.d/defguard | |
example-config.toml=/etc/defguard/gateway.toml | |
defguard-rc.conf=/etc/rc.conf.d/defguard | |
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: "--debug -t freebsd --version=${{ env.VERSION }} -p defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.txz" | |
- name: Upload freebsd | |
if: matrix.build == 'freebsd' | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.txz | |
asset_name: defguard-gateway_${{ env.VERSION }}_${{ matrix.target }}.txz | |
asset_content_type: application/octet-stream |