Skip to content

Commit 2b7110e

Browse files
committed
feat: Add Alauda release automation and documentation (#2)
- Add GitHub Actions workflows for automated tagging and releases - Add GoReleaser configuration for Alauda builds - Add development documentation for branch maintenance
1 parent 58b778b commit 2b7110e

File tree

5 files changed

+258
-0
lines changed

5 files changed

+258
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Auto Tag for Alauda
2+
3+
on:
4+
push:
5+
branches:
6+
- 'alauda-v*'
7+
8+
permissions:
9+
contents: write # create tags and releases
10+
packages: write # upload packages
11+
12+
jobs:
13+
tag:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # fetch all tags
20+
21+
- name: Set up Git
22+
run: |
23+
git config user.name "github-actions[bot]"
24+
git config user.email "github-actions[bot]@users.noreply.github.com"
25+
26+
- name: Extract version and tag prefix
27+
id: extract
28+
run: |
29+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
30+
echo "Branch: $BRANCH_NAME"
31+
32+
PREFIX="${BRANCH_NAME%%-*}" # alauda
33+
BASE_VERSION="${BRANCH_NAME#${PREFIX}-}" # v0.62.1
34+
35+
VERSION_NO_V="${BASE_VERSION#v}" # 0.62.1
36+
MAJOR=$(echo "$VERSION_NO_V" | cut -d. -f1)
37+
MINOR=$(echo "$VERSION_NO_V" | cut -d. -f2)
38+
PATCH=$(echo "$VERSION_NO_V" | cut -d. -f3)
39+
40+
echo "MAJOR: $MAJOR, MINOR: $MINOR, PATCH: $PATCH"
41+
42+
# PATCH + 1
43+
NEXT_PATCH=$((PATCH + 1))
44+
echo "NEXT_PATCH=$NEXT_PATCH"
45+
46+
NEXT_VERSION="v${MAJOR}.${MINOR}.${NEXT_PATCH}" # v0.62.2
47+
echo "NEXT_VERSION=$NEXT_VERSION"
48+
49+
TAG_PREFIX="${NEXT_VERSION}-${PREFIX}" # v0.62.2-alauda
50+
echo "TAG_PREFIX=$TAG_PREFIX"
51+
52+
echo "prefix=$PREFIX" >> $GITHUB_OUTPUT
53+
echo "base_version=$BASE_VERSION" >> $GITHUB_OUTPUT
54+
echo "tag_prefix=$TAG_PREFIX" >> $GITHUB_OUTPUT
55+
56+
- name: Find latest tag with this prefix
57+
id: latest
58+
run: |
59+
TAG_PREFIX="${{ steps.extract.outputs.tag_prefix }}"
60+
echo "Looking for tags with prefix: $TAG_PREFIX"
61+
62+
EXISTING_TAGS=$(git tag --list "${TAG_PREFIX}-*" | sort -V)
63+
echo "Existing tags: $EXISTING_TAGS"
64+
65+
MAX_INDEX=-1
66+
for tag in $EXISTING_TAGS; do
67+
NUM=${tag##*-}
68+
if [[ "$NUM" =~ ^[0-9]+$ && "$NUM" -gt "$MAX_INDEX" ]]; then
69+
MAX_INDEX=$NUM
70+
fi
71+
done
72+
73+
NEW_INDEX=$((MAX_INDEX + 1))
74+
NEW_TAG="${TAG_PREFIX}-${NEW_INDEX}"
75+
76+
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
77+
78+
- name: Create and push new tag
79+
run: |
80+
NEW_TAG="${{ steps.latest.outputs.new_tag }}"
81+
git tag "$NEW_TAG"
82+
git push origin "$NEW_TAG"
83+
84+
release-alauda:
85+
name: Release Alauda
86+
needs: [tag]
87+
uses: ./.github/workflows/reusable-release-alauda.yaml
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Release Alauda
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*-alauda-*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write # create releases
11+
packages: write # upload packages
12+
13+
jobs:
14+
release-alauda:
15+
name: Release Alauda
16+
uses: ./.github/workflows/reusable-release-alauda.yaml
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release Alauda
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: write
8+
packages: write
9+
10+
jobs:
11+
release:
12+
name: alauda-release
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/[email protected]
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version-file: go.mod
25+
cache: false
26+
27+
- name: Set up GoReleaser
28+
uses: goreleaser/goreleaser-action@v6
29+
with:
30+
version: v2.1.0
31+
args: release -f=.goreleaser-alauda.yml
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser-alauda.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
4+
# The lines below are called `modelines`. See `:help modeline`
5+
# Feel free to remove those if you don't want/need to use them.
6+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8+
9+
version: 2
10+
11+
before:
12+
hooks:
13+
# You may remove this if you don't use go modules.
14+
- go mod tidy
15+
16+
builds:
17+
- id: golangci-lint
18+
env:
19+
- CGO_ENABLED=0
20+
goos:
21+
- linux
22+
goarch:
23+
- amd64
24+
- arm64
25+
ldflags:
26+
- -w -s -extldflags '-static'
27+
main: ./cmd/golangci-lint/
28+
binary: alauda-golangci-lint
29+
30+
archives:
31+
- id: archive
32+
format: tar.gz
33+
name_template: >-
34+
{{ .ProjectName }}_
35+
{{- title .Os }}_
36+
{{- if eq .Arch "amd64" }}x86_64
37+
{{- else if eq .Arch "386" }}i386
38+
{{- else }}{{ .Arch }}{{ end }}
39+
{{- if .Arm }}v{{ .Arm }}{{ end }}
40+
format_overrides:
41+
- goos: windows
42+
format: zip
43+
44+
changelog:
45+
sort: asc
46+
filters:
47+
exclude:
48+
- "^docs:"
49+
- "^test:"
50+
51+
release:
52+
footer: >-
53+
54+
---
55+
56+
This release is intended for use only as part of the Alauda product suite.
57+
It is not recommended for use by individuals or teams outside of Alauda.
58+
Any consequences arising from its use are the sole responsibility of the user.

DEVELOPMENT.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Golangci-lint alauda Branch Development Guide
2+
3+
## Background
4+
5+
Previously, golangci-lint was used as a general-purpose CLI across multiple plugins, each needing to fix vulnerabilities in golangci-lint independently.
6+
7+
To avoid duplicated efforts, we forked the [golangci-lint](https://github.com/golangci/golangci-lint) repository and maintain it through branches named `alauda-vx.xx.xx`.
8+
9+
We use [renovate](https://gitlab-ce.alauda.cn/devops/tech-research/renovate/-/blob/main/docs/quick-start/0002-quick-start.md) to automatically fix vulnerabilities in corresponding versions.
10+
11+
## Repository Structure
12+
13+
Based on the original code, the following content has been added:
14+
15+
- [alauda-auto-tag.yaml](./.github/workflows/alauda-auto-tag.yaml): Automatically tags and triggers goreleaser when a PR is merged into the `alauda-vx.xx.xx` branch
16+
- [release-alauda.yaml](./.github/workflows/release-alauda.yaml): Supports triggering goreleaser manually or upon tag updates (this pipeline isn't triggered when tags are created by actions due to GitHub Actions design limitations)
17+
- [reusable-release-alauda.yaml](./.github/workflows/reusable-release-alauda.yaml): Executes goreleaser to create a release
18+
- [scan-alauda.yaml](.github/workflows/scan-alauda.yaml): Runs trivy vulnerability scans (`rootfs` scans for Go binaries)
19+
- [.goreleaser-alauda.yml](.goreleaser-alauda.yml): Configuration file for releasing alauda versions
20+
21+
## Special Modifications
22+
23+
None at present
24+
25+
## Pipelines
26+
27+
### Triggered on PR Submission
28+
29+
- [tests.yaml](.github/workflows/tests.yaml): Official testing pipeline including unit tests, integration tests, etc.
30+
31+
### Triggered on Merge to alauda-vx.xx.xx Branch
32+
33+
- [alauda-auto-tag.yaml](.github/workflows/alauda-auto-tag.yaml): Automatically tags and triggers goreleaser
34+
- [reusable-release-alauda.yaml](.github/workflows/reusable-release-alauda.yaml): Executes goreleaser to create a release (triggered by `alauda-auto-tag.yaml`)
35+
36+
### Scheduled or Manual Triggering
37+
38+
- [scan-alauda.yaml](.github/workflows/scan-alauda.yaml): Runs trivy vulnerability scans (`rootfs` scans for Go binaries)
39+
40+
### Others
41+
42+
Other officially maintained pipelines remain unchanged; some irrelevant pipelines have been disabled on the Actions page.
43+
44+
## Renovate Vulnerability Fix Mechanism
45+
46+
The renovate configuration file is [renovate.json](https://github.com/AlaudaDevops/trivy/blob/main/renovate.json)
47+
48+
1. renovate detects vulnerabilities in the branch and submits a PR for fixes
49+
2. Tests run automatically on the PR
50+
3. After all tests pass, renovate automatically merges the PR
51+
4. After the branch updates, an action automatically tags the commit (e.g., v0.62.1-alauda-0, with patch version and last digit incremented)
52+
5. goreleaser automatically publishes a release based on the tag
53+
54+
## Maintenance Plan
55+
56+
When upgrading to a new version, follow these steps:
57+
58+
1. Create an alauda branch from the corresponding tag, e.g., tag `v0.62.1` corresponds to branch `alauda-v0.62.1`
59+
2. Cherry-pick previous alauda branch changes onto the new branch and push
60+
61+
Renovate automatic fix mechanism:
62+
1. After renovate submits a PR, pipelines run automatically; if all tests pass, the PR will be merged automatically
63+
2. After merging into the `alauda-v0.62.1` branch, goreleaser will automatically create a `v0.62.2-alauda-0` release (note: not `v0.62.1-alauda-0`, because upgrading the version allows renovate to recognize it)
64+
3. renovate configured in other plugins will automatically fetch artifacts from the release according to its configuration

0 commit comments

Comments
 (0)