-
Notifications
You must be signed in to change notification settings - Fork 4
138 lines (116 loc) · 4.69 KB
/
pre-release.yml
File metadata and controls
138 lines (116 loc) · 4.69 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
129
130
131
132
133
134
135
136
137
138
name: Pre-release
on:
push:
branches:
- main
env:
GO_VERSION: "1.24"
permissions:
contents: write
id-token: write
attestations: write
jobs:
pre-release:
name: Pre-release
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Check for Go file changes
id: go_changes
run: |
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LATEST_TAG" ]; then
echo "No previous tags found, assuming Go files changed"
echo "changed=true" >> $GITHUB_OUTPUT
else
# Check if any Go files changed since the last tag
GO_CHANGES=$(git diff --name-only ${LATEST_TAG}..HEAD -- '*.go' 'go.mod' 'go.sum' | wc -l)
if [ "$GO_CHANGES" -gt 0 ]; then
echo "Go files changed since ${LATEST_TAG}"
echo "changed=true" >> $GITHUB_OUTPUT
git diff --name-only ${LATEST_TAG}..HEAD -- '*.go' 'go.mod' 'go.sum'
else
echo "No Go files changed since ${LATEST_TAG}"
echo "changed=false" >> $GITHUB_OUTPUT
fi
fi
- name: Set up Go
if: steps.go_changes.outputs.changed == 'true'
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Import GPG key
if: steps.go_changes.outputs.changed == 'true'
id: import_gpg
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Generate snapshot version
if: steps.go_changes.outputs.changed == 'true'
id: version
run: |
# Get the latest release tag (exclude pre-release tags)
LATEST_TAG=$(git tag -l 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1 || echo "v0.0.0")
if [ -z "$LATEST_TAG" ]; then
LATEST_TAG="v0.0.0"
fi
echo "Latest release tag: ${LATEST_TAG}"
# Remove 'v' prefix
VERSION=${LATEST_TAG#v}
echo "Version without prefix: ${VERSION}"
# Parse version components
IFS='.' read -r major minor patch <<< "$VERSION"
echo "Version components: major=${major}, minor=${minor}, patch=${patch}"
# Generate new version
NEW_VERSION="${major}.${minor}.$((patch + 1))-dev.$(date +%Y%m%d%H%M%S)+$(git rev-parse --short HEAD)"
echo "Pre-release version: ${NEW_VERSION}"
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
- name: Run GoReleaser (snapshot)
if: steps.go_changes.outputs.changed == 'true'
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6
with:
version: latest
args: release --snapshot --skip=sign --clean --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate pre-release attestations
if: steps.go_changes.outputs.changed == 'true'
uses: actions/attest-build-provenance@96b4a1ef7235a096b17240c259729fdd70c83d45 # v2
with:
subject-path: |
dist/*.zip
dist/*_checksums.txt
- name: Upload artifacts
if: steps.go_changes.outputs.changed == 'true'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: pre-release-artifacts
path: dist/*
- name: Create GitHub pre-release
if: steps.go_changes.outputs.changed == 'true'
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2
with:
name: "Development Build v${{ steps.version.outputs.version }}"
tag_name: "v${{ steps.version.outputs.version }}"
prerelease: true
draft: false
files: |
dist/*.zip
dist/*_checksums.txt
body: |
## Development Build
This is an automated development build from commit ${{ github.sha }}.
**⚠️ This is a pre-release version and should not be used in production.**
### Commit Information
- SHA: ${{ github.sha }}
- Author: ${{ github.actor }}
- Message: ${{ github.event.head_commit.message }}
### Installation
Download the appropriate archive for your platform and extract the provider binary.