Skip to content

Commit 0292785

Browse files
authored
Merge pull request #16 from wenxuan0923/test-release-workflow
Add new release workflow and refine systemd sudoers permission
2 parents b5d8fd7 + ec980e5 commit 0292785

12 files changed

Lines changed: 1085 additions & 727 deletions

File tree

.github/workflows/release.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Tag to release'
11+
required: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build:
18+
name: Build and Release
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
include:
23+
- os: linux
24+
arch: amd64
25+
goarch: amd64
26+
- os: linux
27+
arch: arm64
28+
goarch: arm64
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Set up Go
37+
uses: actions/setup-go@v4
38+
with:
39+
go-version: '1.23'
40+
41+
- name: Get version
42+
id: version
43+
run: |
44+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
45+
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
46+
else
47+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
48+
fi
49+
50+
- name: Build binary
51+
env:
52+
GOOS: ${{ matrix.os }}
53+
GOARCH: ${{ matrix.goarch }}
54+
run: |
55+
VERSION="${{ steps.version.outputs.VERSION }}"
56+
GIT_COMMIT=$(git rev-parse --short HEAD)
57+
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
58+
59+
LDFLAGS="-X main.Version=${VERSION} -X main.GitCommit=${GIT_COMMIT} -X main.BuildTime=${BUILD_DATE} -w -s"
60+
61+
BINARY_NAME="aks-flex-node-${{ matrix.os }}-${{ matrix.arch }}"
62+
63+
go build -ldflags "${LDFLAGS}" -o "${BINARY_NAME}" .
64+
65+
# Create tarball
66+
tar -czf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}"
67+
echo "ASSET=${BINARY_NAME}.tar.gz" >> $GITHUB_ENV
68+
69+
- name: Upload artifacts
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: binaries-${{ matrix.os }}-${{ matrix.arch }}
73+
path: ${{ env.ASSET }}
74+
75+
release:
76+
name: Create Release
77+
needs: build
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout code
81+
uses: actions/checkout@v4
82+
83+
- name: Get version
84+
id: version
85+
run: |
86+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
87+
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
88+
else
89+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
90+
fi
91+
92+
- name: Download artifacts
93+
uses: actions/download-artifact@v4
94+
with:
95+
pattern: binaries-*
96+
path: ./artifacts
97+
merge-multiple: true
98+
99+
- name: Generate checksums
100+
run: |
101+
cd artifacts
102+
sha256sum * > checksums.txt
103+
104+
- name: Create Release
105+
uses: softprops/action-gh-release@v1
106+
with:
107+
tag_name: ${{ steps.version.outputs.VERSION }}
108+
name: Release ${{ steps.version.outputs.VERSION }}
109+
body: |
110+
## AKS Flex Node ${{ steps.version.outputs.VERSION }}
111+
112+
### Installation
113+
114+
**Quick install (Ubuntu 22.04/20.04):**
115+
```bash
116+
curl -fsSL https://raw.githubusercontent.com/Azure/AKSFlexNode/main/scripts/install.sh | bash
117+
```
118+
119+
**Manual installation:**
120+
1. Download the appropriate binary for your platform
121+
2. Extract the archive: `tar -xzf aks-flex-node-*.tar.gz`
122+
3. Move the binary to your PATH: `sudo mv aks-flex-node-* /usr/local/bin/aks-flex-node`
123+
4. Make it executable: `sudo chmod +x /usr/local/bin/aks-flex-node`
124+
125+
### Supported Platforms
126+
127+
- **Ubuntu 22.04 LTS (AMD64)**: `aks-flex-node-linux-amd64.tar.gz`
128+
- **Ubuntu 22.04 LTS (ARM64)**: `aks-flex-node-linux-arm64.tar.gz`
129+
- **Ubuntu 24.04 LTS**: Compatible with AMD64 and ARM64 binaries above
130+
131+
### Verification
132+
133+
Verify your download with the checksums in `checksums.txt`.
134+
135+
### What's Changed
136+
137+
<!-- Add your changelog here -->
138+
files: |
139+
artifacts/*
140+
draft: false
141+
prerelease: false

AKSFlexNode

-16.8 MB
Binary file not shown.

Makefile

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,79 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
44
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
55

66
# Build flags to inject version information
7-
LDFLAGS := -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTime=$(BUILD_DATE)
7+
LDFLAGS := -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildTime=$(BUILD_DATE) -w -s
88

9+
# Default build for current platform
910
.PHONY: build
1011
build:
12+
@echo "Building for current platform..."
1113
@go build -ldflags "$(LDFLAGS)" -o aks-flex-node .
1214

15+
# Cross-platform builds for supported architectures
16+
.PHONY: build-linux-amd64
17+
build-linux-amd64:
18+
@echo "Building for Linux AMD64..."
19+
@GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o aks-flex-node-linux-amd64 .
20+
21+
.PHONY: build-linux-arm64
22+
build-linux-arm64:
23+
@echo "Building for Linux ARM64..."
24+
@GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o aks-flex-node-linux-arm64 .
25+
26+
# Build all supported platforms
27+
.PHONY: build-all
28+
build-all: build-linux-amd64 build-linux-arm64
29+
@echo "Built binaries for all supported platforms"
30+
31+
# Create release archives
32+
.PHONY: package-linux-amd64
33+
package-linux-amd64: build-linux-amd64
34+
@echo "Packaging Linux AMD64 binary..."
35+
@tar -czf aks-flex-node-linux-amd64.tar.gz aks-flex-node-linux-amd64
36+
37+
.PHONY: package-linux-arm64
38+
package-linux-arm64: build-linux-arm64
39+
@echo "Packaging Linux ARM64 binary..."
40+
@tar -czf aks-flex-node-linux-arm64.tar.gz aks-flex-node-linux-arm64
41+
42+
# Package all supported platforms
43+
.PHONY: package-all
44+
package-all: package-linux-amd64 package-linux-arm64
45+
@echo "Packaged all supported platforms"
46+
@ls -la *.tar.gz
47+
1348
.PHONY: test
1449
test:
1550
@go test ./...
1651

1752
.PHONY: clean
1853
clean:
54+
@echo "Cleaning build artifacts..."
1955
@go clean
56+
@rm -f aks-flex-node-*
57+
@rm -f *.tar.gz
2058

2159
.PHONY: update-build-metadata
2260
update-build-metadata:
2361
@echo "📅 Build Date: $(BUILD_DATE)"
24-
@echo "🎯 Git Commit: $(GIT_COMMIT)"
62+
@echo "🎯 Git Commit: $(GIT_COMMIT)"
63+
@echo "🏷️ Version: $(VERSION)"
64+
65+
# Help target
66+
.PHONY: help
67+
help:
68+
@echo "AKS Flex Node Makefile"
69+
@echo "======================"
70+
@echo ""
71+
@echo "Targets:"
72+
@echo " build Build for current platform"
73+
@echo " build-linux-amd64 Build for Linux AMD64"
74+
@echo " build-linux-arm64 Build for Linux ARM64"
75+
@echo " build-all Build for all supported platforms"
76+
@echo " package-linux-amd64 Package Linux AMD64 binary"
77+
@echo " package-linux-arm64 Package Linux ARM64 binary"
78+
@echo " package-all Package all supported platforms"
79+
@echo " test Run tests"
80+
@echo " clean Clean build artifacts"
81+
@echo " update-build-metadata Show build metadata"
82+
@echo " help Show this help message"

0 commit comments

Comments
 (0)