-
Notifications
You must be signed in to change notification settings - Fork 7
128 lines (112 loc) · 3.55 KB
/
Copy pathrelease-plugin.yml
File metadata and controls
128 lines (112 loc) · 3.55 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: "Release: Plugin"
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. v0.1.0)'
required: true
dry_run:
description: 'Push to staging only, skip promotion and release'
type: boolean
default: false
jobs:
validate:
name: Validate
runs-on: ubuntu-latest
outputs:
version: ${{ steps.validate.outputs.version }}
short_sha: ${{ steps.validate.outputs.short_sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Validate inputs
id: validate
run: |
VERSION="${{ inputs.version }}"
if ! echo "$VERSION" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
echo "::error::Invalid version format: $VERSION (expected vX.Y.Z or vX.Y.Z-prerelease)"
exit 1
fi
TAG="plugin/$VERSION"
if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
echo "::error::Tag $TAG already exists"
exit 1
fi
if [ "${{ inputs.dry_run }}" != "true" ]; then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" != "main" ]; then
echo "::error::Release must be from main branch (currently on $BRANCH). Use dry_run for testing from other branches."
exit 1
fi
fi
SHORT_SHA=$(git rev-parse --short HEAD)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
echo "## Plugin release validation passed" >> "$GITHUB_STEP_SUMMARY"
echo "- Version: $VERSION" >> "$GITHUB_STEP_SUMMARY"
echo "- Tag: $TAG" >> "$GITHUB_STEP_SUMMARY"
echo "- SHA: $SHORT_SHA" >> "$GITHUB_STEP_SUMMARY"
echo "- Dry run: ${{ inputs.dry_run }}" >> "$GITHUB_STEP_SUMMARY"
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v7
with:
version: v2.4.0
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make test
stage-image:
name: Stage image
needs: [validate, lint, test]
uses: ./.github/workflows/release-stage-plugin-image.yml
with:
version: ${{ inputs.version }}
short_sha: ${{ needs.validate.outputs.short_sha }}
permissions:
contents: read
packages: write
promote-image:
name: Promote image
needs: [stage-image]
if: inputs.dry_run == false
uses: ./.github/workflows/release-promote-plugin-image.yml
with:
version: ${{ inputs.version }}
short_sha: ${{ needs.stage-image.outputs.short_sha }}
permissions:
contents: read
packages: write
release:
name: Create release
needs: [promote-image]
if: inputs.dry_run == false
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create tag
run: |
git tag plugin/${{ inputs.version }}
git push origin plugin/${{ inputs.version }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: plugin/${{ inputs.version }}
name: "aws-plugin ${{ inputs.version }}"
generate_release_notes: true