mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-09 14:46:36 +08:00
Merge pull request #2041 from gravitl/gra_1100-netmaker
Gra 1100 netmaker
This commit is contained in:
commit
36210264c4
6 changed files with 53 additions and 48 deletions
53
.github/workflows/buildandrelease.yml
vendored
53
.github/workflows/buildandrelease.yml
vendored
|
@ -13,61 +13,38 @@ jobs:
|
||||||
version:
|
version:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
tag: ${{ steps.echo.outputs.tag }}
|
tag: ${{ steps.version.outputs.package_version }}
|
||||||
version: ${{ steps.echo.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Get Version Number
|
- name: Get Version Number
|
||||||
|
id: version
|
||||||
run: |
|
run: |
|
||||||
if [[ -n "${{ github.event.inputs.version }}" ]]; then
|
if [[ -n "${{ github.event.inputs.version }}" ]]; then
|
||||||
NETMAKER_VERSION=${{ github.event.inputs.version }}
|
NETMAKER_VERSION=${{ github.event.inputs.version }}
|
||||||
else
|
else
|
||||||
NETMAKER_VERSION=$(curl -fsSL https://api.github.com/repos/gravitl/netmaker/tags | grep 'name' | head -1 | cut -d'"' -f4)
|
NETMAKER_VERSION=$(curl -fsSL https://api.github.com/repos/gravitl/netmaker/tags | grep 'name' | head -1 | cut -d'"' -f4)
|
||||||
fi
|
fi
|
||||||
echo "NETMAKER_VERSION=${NETMAKER_VERSION}" >> $GITHUB_ENV
|
echo "VERSION=${NETMAKER_VERSION}" >> $GITHUB_OUTPUT
|
||||||
# remove everything but digits and . for package (deb, rpm, etc) versions
|
# remove everything but digits and . for package (deb, rpm, etc) versions
|
||||||
PACKAGE_VERSION=$(echo ${NETMAKER_VERSION} | tr -cd '[:digit:].')
|
PACKAGE_VERSION=$(echo ${NETMAKER_VERSION} | tr -cd '[:digit:].')
|
||||||
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
|
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
|
||||||
- name: Echo
|
netmaker-nmctl:
|
||||||
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
|
runs-on: ubuntu-latest
|
||||||
needs: version
|
needs: version
|
||||||
steps:
|
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
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: release_${{ needs.version.outputs.version }}
|
||||||
|
fetch-depth: 0
|
||||||
|
- run: git fetch --force --tags
|
||||||
- name: Setup go
|
- name: Setup go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.19
|
go-version: 1.19
|
||||||
- name: Build
|
- name: GoReleaser
|
||||||
run: |
|
uses: goreleaser/goreleaser-action@v4
|
||||||
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netmaker main.go
|
|
||||||
- name: Upload netmaker x86 to Release
|
|
||||||
uses: svenstaro/upload-release-action@v2
|
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
args: release --clean
|
||||||
file: build/netmaker
|
env:
|
||||||
tag: ${{ env.NETMAKER_VERSION }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
overwrite: true
|
|
||||||
prerelease: true
|
|
||||||
asset_name: netmaker
|
|
||||||
|
|
||||||
|
|
5
.github/workflows/docker-builder.yml
vendored
5
.github/workflows/docker-builder.yml
vendored
|
@ -2,8 +2,9 @@ name: Build go-builder images
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
push:
|
||||||
- cron: '00 21 * * SUN'
|
branches:
|
||||||
|
- 'develop'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
go-builder:
|
go-builder:
|
||||||
|
|
2
.github/workflows/publish-docker.yml
vendored
2
.github/workflows/publish-docker.yml
vendored
|
@ -48,7 +48,6 @@ jobs:
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ github.repository }}:${{ env.TAG }}, ${{ github.repository }}:latest
|
tags: ${{ github.repository }}:${{ env.TAG }}, ${{ github.repository }}:latest
|
||||||
build-args: |
|
build-args: |
|
||||||
version=${{ env.TAG }}
|
|
||||||
tags=ce
|
tags=ce
|
||||||
|
|
||||||
docker-ee:
|
docker-ee:
|
||||||
|
@ -89,5 +88,4 @@ jobs:
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ github.repository }}:${{ env.TAG }}-ee
|
tags: ${{ github.repository }}:${{ env.TAG }}-ee
|
||||||
build-args: |
|
build-args: |
|
||||||
version=${{ env.TAG }}
|
|
||||||
tags=ee
|
tags=ee
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -24,3 +24,4 @@ data/
|
||||||
.idea/
|
.idea/
|
||||||
netmaker.exe
|
netmaker.exe
|
||||||
netmaker.code-workspace
|
netmaker.code-workspace
|
||||||
|
dist/
|
||||||
|
|
33
.goreleaser.yaml
Normal file
33
.goreleaser.yaml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
# You may remove this if you don't use go modules.
|
||||||
|
- go mod tidy
|
||||||
|
builds:
|
||||||
|
- main: ./
|
||||||
|
id: "netmaker"
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
targets:
|
||||||
|
- linux_amd64
|
||||||
|
binary: netmaker
|
||||||
|
- main: ./cli
|
||||||
|
id: "nmctl"
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
targets:
|
||||||
|
- linux_amd64
|
||||||
|
- linux_arm64
|
||||||
|
- darwin_amd64
|
||||||
|
- darwin_arm64
|
||||||
|
- freebsd_amd64
|
||||||
|
- windows_amd64
|
||||||
|
binary: nmctl
|
||||||
|
archives:
|
||||||
|
- format: binary
|
||||||
|
name_template: '{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}'
|
||||||
|
changelog:
|
||||||
|
skip: true
|
|
@ -1,18 +1,13 @@
|
||||||
#first stage - builder
|
#first stage - builder
|
||||||
FROM gravitl/go-builder as builder
|
FROM gravitl/go-builder as builder
|
||||||
ARG version
|
|
||||||
ARG tags
|
ARG tags
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV GO111MODULE=auto
|
|
||||||
|
|
||||||
RUN apk add git
|
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -w" -tags ${tags} .
|
||||||
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=${version}'" -tags ${tags} .
|
|
||||||
# RUN go build -tags=ee . -o netmaker main.go
|
# RUN go build -tags=ee . -o netmaker main.go
|
||||||
FROM alpine:3.16.2
|
FROM alpine:3.16.2
|
||||||
|
|
||||||
# add a c lib
|
|
||||||
RUN apk add gcompat iptables wireguard-tools
|
|
||||||
# set the working directory
|
# set the working directory
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
RUN mkdir -p /etc/netclient/config
|
RUN mkdir -p /etc/netclient/config
|
||||||
|
|
Loading…
Add table
Reference in a new issue