-
Notifications
You must be signed in to change notification settings - Fork 40
111 lines (96 loc) · 3.33 KB
/
Copy pathamctl_release.yaml
File metadata and controls
111 lines (96 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: amctl CLI Release
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to release from"
required: true
default: "main"
type: string
target_version:
description: "Target version for the release (e.g., 0.1.0)"
required: true
type: string
run-name: amctl Release ${{ inputs.target_version }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- name: Setup Go
uses: actions/setup-go@v6.1.0
with:
go-version-file: cli/go.mod
cache-dependency-path: cli/go.sum
- name: Run tests
run: cd cli && go test ./... -v
release:
name: Release
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6.1.0
with:
go-version-file: cli/go.mod
cache-dependency-path: cli/go.sum
- name: Validate and set release metadata
env:
TARGET_VERSION: ${{ inputs.target_version }}
run: |
if ! [[ "$TARGET_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "Error: target_version must be semver (e.g., 1.2.3 or 1.2.3-rc.1)"
exit 1
fi
printf 'VERSION=%s\n' "$TARGET_VERSION" >> "$GITHUB_ENV"
printf 'RELEASE_TAG=amctl/v%s\n' "$TARGET_VERSION" >> "$GITHUB_ENV"
if [[ "$TARGET_VERSION" == *-* ]]; then
echo "IS_PRERELEASE=true" >> "$GITHUB_ENV"
else
echo "IS_PRERELEASE=false" >> "$GITHUB_ENV"
fi
- name: Check tag does not already exist
run: |
if git ls-remote --tags origin "$RELEASE_TAG" | grep -q "$RELEASE_TAG"; then
echo "Error: Tag $RELEASE_TAG already exists. Please use a different version."
exit 1
fi
- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$RELEASE_TAG" -m "Release amctl v${VERSION}"
git push origin "$RELEASE_TAG"
- name: Build release artifacts
run: |
scripts/build-amctl.sh \
--version "$VERSION" \
--commit "$(git rev-parse --short HEAD)" \
--date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--output-dir dist/
- name: Create draft GitHub release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
tag_name: ${{ env.RELEASE_TAG }}
name: "WSO2 Agent Manager - CLI amctl v${{ env.VERSION }}"
draft: true
prerelease: ${{ env.IS_PRERELEASE == 'true' }}
body: |
## amctl v${{ env.VERSION }}
**Commit:** ${{ github.sha }}
**Date:** ${{ github.event.repository.updated_at }}
**Branch:** ${{ inputs.branch }}
---
_This is a draft release. Edit this description to add release notes before publishing._
files: dist/*