Merge pull request #889 from gravitl/worklows

Add packages (deb, rpm, pacman) to build and release workflow
This commit is contained in:
dcarns 2022-03-15 09:19:28 -04:00 committed by GitHub
commit 5ffa53f5de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 265 additions and 34 deletions

8
.fpm Normal file
View file

@ -0,0 +1,8 @@
--name netclient
--license sspl
--depends wireguard-tools
--description "Netmaker's netclient agent and CLI"
--url "https//:github.com/gravitl/netmaker"
--maintainer "info@gravitl.com"
--vendor Gravitl

View file

@ -5,16 +5,17 @@ on:
inputs:
version:
description: 'Netmaker version'
required: false
required: true
release:
types: [published]
jobs:
build:
version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.echo.outputs.tag }}
version: ${{ steps.echo.outputs.version }}
steps:
- name: Get Version Number
run: |
if [[ -n "${{ github.event.inputs.version }}" ]]; then
@ -23,32 +24,43 @@ jobs:
NETMAKER_VERSION=$(curl -fsSL https://api.github.com/repos/gravitl/netmaker/tags | grep 'name' | head -1 | cut -d'"' -f4)
fi
echo "NETMAKER_VERSION=${NETMAKER_VERSION}" >> $GITHUB_ENV
# remove everything but digits and . for package (deb, rpm, etc) versions
PACKAGE_VERSION=$(echo ${NETMAKER_VERSION} | tr -cd '[:digit:].')
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
- name: Echo
id: echo
run: |
echo ${{ env.NETMAKER_VERSION }}
echo ${{ env.PACKAGE_VERSION }}
if [[ -z ${{ env.NETMAKER_VERSION }} || -z ${{ env.PACKAGE_VERSION }} ]]
then
exit 1
fi
echo "::set-output name=tag::${{ env.NETMAKER_VERSION }}"
echo "::set-output name=version::${{ env.PACKAGE_VERSION }}"
netmaker:
runs-on: ubuntu-latest
needs: version
steps:
- name: set variables
run: |
echo ${{ needs.version.outputs.tag }} ${{ needs.version.outputs.version }}
TAG=${{needs.version.outputs.tag}}
VERSION=${{needs.version.outputs.version}}
if [[ -z ${VERSION} || -z ${TAG} ]]; then
exit 1
fi
echo "NETMAKER_VERSION=${TAG}" >> $GITHUB_ENV
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: |
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netmaker main.go
cd netclient
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm5/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm6/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm7/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm64/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -X 'main.version=$NETMAKER_VERSION'" -o build/netclient-mipsle/netclient main.go && upx build/netclient-mipsle/netclient
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-X 'main.Version=${NETMAKER_VERSION}'" -o build/netclient-freebsd/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=5 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm5/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm6/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=7 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm7/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm64/netclient main.go
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-darwin/netclient main.go
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-darwin-arm64/netclient main.go
- name: Upload netmaker x86 to Release
uses: svenstaro/upload-release-action@v2
with:
@ -59,7 +71,28 @@ jobs:
prerelease: true
asset_name: netmaker
- name: Upload x86 to Release
netclient-x86:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Variables
run: |
TAG=${{needs.version.outputs.tag}}
VERSION=${{needs.version.outputs.version}}
echo "NETMAKER_VERSION=${TAG}" >> $GITHUB_ENV
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: |
cd netclient
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient main.go
- name: Upload netclient x86 to Release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
@ -69,26 +102,100 @@ jobs:
prerelease: true
asset_name: netclient
- name: Upload arm5 to Release
- name: Package x86 deb
continue-on-error: true
uses: gravitl/github-action-fpm@master
with:
fpm_args: './netclient/build/netclient=/sbin/netclient ./netclient/build/netclient.service=/lib/systemd/system/netclient.service'
fpm_opts: '-s dir -t deb --architecture amd64 --version ${{ env.PACKAGE_VERSION }}'
- name: Upload x86 deb to Release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: netclient/build/netclient-arm5/netclient
file: netclient_${{ env.PACKAGE_VERSION }}_amd64.deb
tag: ${{ env.NETMAKER_VERSION }}
overwrite: true
prerelease: true
asset_name: netclient_${{ env.PACKAGE_VERSION }}_amd64.deb
- name: Package x86 rpm
continue-on-error: true
uses: gravitl/github-action-fpm@master
with:
fpm_args: './netclient/build/netclient=/sbin/netclient ./netclient/build/netclient.service=/lib/systemd/system/netclient.service'
fpm_opts: '-s dir -t rpm --architecture amd64 --version ${{ env.PACKAGE_VERSION }}'
- name: Upload x86 rpm to Release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: netclient-${{ env.PACKAGE_VERSION }}-1.x86_64.rpm
tag: ${{ env.NETMAKER_VERSION }}
overwrite: true
prerelease: true
asset_name: netclient-${{ env.PACKAGE_VERSION }}-1.x86_64.rpm
- name: Package x86 pacman
continue-on-error: true
uses: gravitl/github-action-fpm@master
with:
# arch has particular path requirements --- cannot write to a symbolic link e.g. /sbin and /lib
fpm_args: './netclient/build/netclient=/usr/bin/netclient ./netclient/build/netclient.service=/usr/lib/systemd/system/netclient.service'
fpm_opts: '-s dir -t pacman --architecture amd64 --version ${{ env.PACKAGE_VERSION }}'
- name: Upload x86 pacman to Release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: netclient-${{ env.PACKAGE_VERSION }}-1-x86_64.pkg.tar.zst
tag: ${{ env.NETMAKER_VERSION }}
overwrite: true
prerelease: true
asset_name: netclient-${{ env.PACKAGE_VERSION }}-1-x86_64.pkg.tar.zst
netclient-arm:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Variables
run: |
TAG=${{needs.version.outputs.tag}}
VERSION=${{needs.version.outputs.version}}
echo "NETMAKER_VERSION=${TAG}" >> $GITHUB_ENV
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: |
cd netclient
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm5/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm6/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm7/netclient main.go
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-arm64/netclient main.go
- name: Upload arm5 to Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: netclient/build/netclient-arm5/netclient
tag: ${{ env.NETMAKER_VERSION }}
overwrite: true
prerelease: true
asset_name: netclient-arm5
- name: Upload arm6 to Release
uses: svenstaro/upload-release-action@v2
with:
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: netclient/build/netclient-arm6/netclient
tag: ${{ env.NETMAKER_VERSION }}
overwrite: true
prerelease: true
asset_name: netclient-arm6
- name: Upload arm7 to Release
uses: svenstaro/upload-release-action@v2
with:
@ -98,8 +205,9 @@ jobs:
overwrite: true
prerelease: true
asset_name: netclient-arm7
- name: Upload arm64 to Release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
@ -108,7 +216,59 @@ jobs:
overwrite: true
prerelease: true
asset_name: netclient-arm64
- name: Package arm64 deb
continue-on-error: true
uses: gravitl/github-action-fpm@master
with:
fpm_args: './netclient/build/netclient-arm64/netclient=/sbin/netclient ./netclient/build/netclient.service=/lib/systemd/netclient.service'
fpm_opts: '-s dir -t deb --architecture arm64 --version ${{ env.PACKAGE_VERSION }}'
- name: Upload arm deb to Release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: netclient_${{ env.PACKAGE_VERSION }}_arm64.deb
tag: ${{ env.NETMAKER_VERSION }}
overwrite: true
prerelease: true
asset_name: netclient_${{ env.PACKAGE_VERSION }}_arm64.deb
- name: Package arm64 rpm
continue-on-error: true
uses: gravitl/github-action-fpm@master
with:
fpm_args: './netclient/build/netclient-arm64/netclient=/sbin/netclient ./netclient/build/netclient.service=/lib/systemd/netclient.service'
fpm_opts: '-s dir -t rpm --architecture arm64 --version ${{ env.PACKAGE_VERSION }}'
- name: Upload arm64 rpm to Release
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: netclient-${{ env.PACKAGE_VERSION }}-1.aarch64.rpm
tag: ${{ env.NETMAKER_VERSION }}
overwrite: true
prerelease: true
asset_name: netclient-${{ env.PACKAGE_VERSION }}-1.aarch4.rpm
netclient-mipsle:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Variables
run: |
TAG=${{needs.version.outputs.tag}}
VERSION=${{needs.version.outputs.version}}
echo "NETMAKER_VERSION=${TAG}" >> $GITHUB_ENV
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: |
cd netclient
env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -X 'main.version=$NETMAKER_VERSION'" -o build/netclient-mipsle/netclient main.go && upx build/netclient-mipsle/netclient
- name: Upload mipsle to Release
uses: svenstaro/upload-release-action@v2
with:
@ -118,6 +278,31 @@ jobs:
overwrite: true
prerelease: true
asset_name: netclient-mipsle
netclient-freebsd:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Variables
run: |
TAG=${{needs.version.outputs.tag}}
VERSION=${{needs.version.outputs.version}}
echo "NETMAKER_VERSION=${TAG}" >> $GITHUB_ENV
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: |
cd netclient
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-X 'main.Version=${NETMAKER_VERSION}'" -o build/netclient-freebsd/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=5 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm5/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm6/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=7 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm7/netclient main.go
env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm64/netclient main.go
- name: Upload freebsd to Release
uses: svenstaro/upload-release-action@v2
@ -168,8 +353,29 @@ jobs:
overwrite: true
prerelease: true
asset_name: netclient-freebsd-arm64
- name: Upload darwin to Release
netclient-darwin:
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Variables
run: |
TAG=${{needs.version.outputs.tag}}
VERSION=${{needs.version.outputs.version}}
echo "NETMAKER_VERSION=${TAG}" >> $GITHUB_ENV
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: |
cd netclient
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-darwin/netclient main.go
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-darwin-arm64/netclient main.go
- name: Upload darwin-arm64 to Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,8 +1,9 @@
name: Purge untagged images from GHCR
on:
workflow_dispatch
workflow_dispatch:
schedule:
- cron: '1 1 1 * *'
jobs:
purge:
runs-on: ubuntu-latest
@ -15,7 +16,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
organization: gravitl
container: netmaker
dry-run: true # Dry-run first, then change to `false`
dry-run: false # Dry-run first, then change to `false`
untagged: true
- name: Prune Netclient
uses: vlaurin/action-ghcr-prune@main
@ -23,6 +24,6 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
organization: gravitl
container: netclient
dry-run: true # Dry-run first, then change to `false`
dry-run: false # Dry-run first, then change to `false`
untagged: true

1
.gitignore vendored
View file

@ -6,6 +6,7 @@ netmaker-amd64
netclient/netclient
netclient/build
netclient/build/
!netclient/build/netclient.service
netclient/files/netclient
netclient/netclient-amd64
netclient/netclient-arm

View file

@ -90,7 +90,7 @@ func GetNodePeers(networkName, nodeid string, excludeRelayed bool, isP2S bool) (
}
}
}
if !isP2S || peer.IsHub == "yes" {
if (!isP2S || peer.IsHub == "yes") && currentNetworkACLs.IsAllowed(acls.AclID(nodeid), acls.AclID(node.ID)) {
peers = append(peers, peer)
}
}

View file

@ -0,0 +1,15 @@
[Unit]
Description=Netclient Daemon
Documentation=https://docs.netmaker.org https://k8s.netmaker.org
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
User=root
Type=simple
ExecStart=/sbin/netclient daemon
Restart=on-failure
RestartSec=15s
[Install]
WantedBy=multi-user.target