make goreleaser work on publish release

This commit is contained in:
Matthew R Kasun 2023-02-15 15:29:42 -05:00
parent 3fcbce7ab6
commit 72180e0980
3 changed files with 17 additions and 12 deletions

View file

@ -13,7 +13,7 @@ jobs:
version: version:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
tag: ${{ steps.version.outputs.tag }} tag: ${{ steps.version.outputs.package_version }}
version: ${{ steps.version.outputs.version }} version: ${{ steps.version.outputs.version }}
steps: steps:
- name: Get Version Number - name: Get Version Number
@ -24,7 +24,7 @@ jobs:
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_OUTPUT 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_OUTPUT echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
@ -34,11 +34,17 @@ jobs:
steps: steps:
- 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: GoReleaser - name: GoReleaser
uses: actions/goreleaser-action@v4 uses: goreleaser/goreleaser-action@v4
with: with:
args: release --clean args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View file

@ -24,3 +24,4 @@ data/
.idea/ .idea/
netmaker.exe netmaker.exe
netmaker.code-workspace netmaker.code-workspace
dist/

View file

@ -4,17 +4,16 @@ before:
- go mod tidy - go mod tidy
builds: builds:
- main: ./ - main: ./
id: netmaker id: "netmaker"
env: env:
- CGO_ENABLED=1 - CGO_ENABLED=1
ldflags: ldflags:
- -s -w - -s -w
targets: targets:
- linux_amd64 - linux_amd64
no_unique_dist_dir: true binary: netmaker
binary: '{{ .id }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}' - main: ./cli
- main: ./cli id: "nmctl"
id: nmctl
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
ldflags: ldflags:
@ -26,10 +25,9 @@ builds:
- darwin_arm64 - darwin_arm64
- freebsd_amd64 - freebsd_amd64
- windows_amd64 - windows_amd64
no_unique_dist_dir: true binary: nmctl
binary: '{{ .id }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}'
archives: archives:
- format: binary - format: binary
name_template: '{{ .id}}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}' name_template: '{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}'
changelog: changelog:
skip: true skip: true