Skip to content

Commit b1f7f7b

Browse files
committed
perf: update Makefile and actions
1 parent 69af82d commit b1f7f7b

File tree

3 files changed

+83
-76
lines changed

3 files changed

+83
-76
lines changed

.github/actions/build-action/action.yml

-23
This file was deleted.

.github/workflows/build.yml

+47-42
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,70 @@
1-
# This is a basic workflow to help you get started with Actions
2-
3-
name: Build And Release
4-
5-
# Controls when the action will run. Triggers the workflow on push or pull request
6-
# events but only for the master branch
71
on:
82
push:
3+
# Sequence of patterns matched against refs/tags
94
tags:
105
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
116

12-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
7+
name: Create Release And Upload assets
8+
139
jobs:
14-
# This workflow contains a single job called "build"
15-
create_release:
10+
create-release:
1611
name: Create Release
1712
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
go_version: [ 'stable' ]
1816
outputs:
1917
upload_url: ${{ steps.create_release.outputs.upload_url }}
2018
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/cache@v4
22+
with:
23+
path: |
24+
~/.npm
25+
~/.cache
26+
~/go/pkg/mod
27+
key: ${{ runner.os }}-build-${{ github.sha }}
28+
restore-keys: ${{ runner.os }}-build-
29+
30+
- name: Get version
31+
id: get_version
32+
run: |
33+
TAG=$(basename ${GITHUB_REF})
34+
echo "TAG=$TAG" >> $GITHUB_OUTPUT
35+
2136
- name: Create Release
2237
id: create_release
23-
uses: actions/create-release@v1
38+
uses: release-drafter/release-drafter@v6
2439
env:
2540
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2641
with:
27-
tag_name: ${{ github.ref }}
28-
release_name: ${{ github.ref }}
29-
draft: true
30-
prerelease: false
42+
config-name: release-config.yml
43+
version: ${{ steps.get_version.outputs.TAG }}
44+
tag: ${{ steps.get_version.outputs.TAG }}
3145

32-
build:
33-
name: Build
34-
needs: create_release
35-
strategy:
36-
matrix:
37-
go-version: [ 1.23.x ]
38-
os: [ ubuntu-latest, macos-latest, windows-latest ]
39-
runs-on: ${{ matrix.os }}
40-
41-
# Steps represent a sequence of tasks that will be executed as part of the job
42-
steps:
43-
- name: Install Go
44-
uses: actions/setup-go@v2
46+
- uses: actions/setup-node@v4
4547
with:
46-
go-version: ${{ matrix.go-version }}
47-
- name: Checkout code
48-
uses: actions/checkout@v2
48+
node-version: ${{ matrix.node_version }}
4949

50-
- name: Build JMS Tool
51-
id: build_jms_tool
52-
uses: ./.github/actions/build-action
50+
- uses: actions/setup-go@v5
5351
with:
54-
GOOS: ${{ matrix.os }}
52+
go-version: ${{ matrix.go_version }}
53+
cache: false
5554

56-
- name: Upload Release Asset
57-
id: upload-release-asset
58-
uses: actions/upload-release-asset@v1
55+
- name: Make Build
56+
id: make_build
57+
run: |
58+
make all -s && ls build
5959
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
VERSION: ${{ steps.get_version.outputs.TAG }}
61+
62+
- name: Release Upload Assets
63+
uses: softprops/action-gh-release@v2
64+
if: startsWith(github.ref, 'refs/tags/')
6165
with:
62-
upload_url: ${{ needs.create_release.outputs.upload_url }}
63-
asset_path: ./${{ steps.build_jms_tool.outputs.filename }}
64-
asset_name: ${{ steps.build_jms_tool.outputs.filename }}
65-
asset_content_type: application/gzip
66+
draft: true
67+
files: |
68+
build/*.gz
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

+36-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11

2+
3+
BUILDDIR=build
4+
LDFLAGS=-w -s
5+
VERSION ?= Unknown
6+
LDFLAGS+=-X golang.org/x/crypto/ssh.debugHandshake=true
7+
NAME=jmstool
8+
29
BUILD_INFO_GIT_TAG ?= $(shell git describe --tags 2>/dev/null || echo unknown)
310
BUILD_INFO_GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
411
BUILD_INFO_BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" || echo unknown)
512

6-
release: linux darwin windows
13+
all: darwin-amd64 darwin-arm64 linux-amd64 linux-arm64 windows
14+
15+
define make_artifact_full
16+
@echo "Building GOOS: $(1) ARCH: $(2)"
17+
mkdir -p $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/
18+
19+
if [ "$(1)" = "windows" ]; then \
20+
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -trimpath -ldflags "${LDFLAGS}" -o $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(NAME).exe .; \
21+
else \
22+
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -trimpath -ldflags "${LDFLAGS}" -o $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(NAME) .; \
23+
fi
24+
cp ssh_config $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/
25+
26+
tar -C $(BUILDDIR) -czf $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2).tar.gz $(NAME)-$(VERSION)-$(1)-$(2)/
27+
rm -rf $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/
28+
endef
29+
30+
darwin-amd64:
31+
$(call make_artifact_full,darwin,amd64)
32+
33+
darwin-arm64:
34+
$(call make_artifact_full,darwin,arm64)
735

8-
.PHONY: linux
9-
linux:
10-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -x -ldflags "-X golang.org/x/crypto/ssh.debugHandshake=true" -o jmstool_linux .
36+
linux-amd64:
37+
$(call make_artifact_full,linux,amd64)
1138

12-
.PHONY: darwin
13-
darwin:
14-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -x -ldflags "-X golang.org/x/crypto/ssh.debugHandshake=true" -o jmstool_darwin .
39+
linux-arm64:
40+
$(call make_artifact_full,linux,arm64)
1541

16-
.PHONY: windows
17-
windows:
18-
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -x -ldflags "-X golang.org/x/crypto/ssh.debugHandshake=true" -o jmstool_windows.exe .
42+
windows-amd64:
43+
$(call make_artifact_full,windows,amd64)
1944

2045

2146
.PHONY: clean
2247
clean:
23-
rm -f jmstool_linux jmstool_darwin jmstool_windows.exe
48+
rm -rf $(BUILDDIR)/*

0 commit comments

Comments
 (0)