-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (52 loc) · 2.04 KB
/
Copy pathrelease.yml
File metadata and controls
60 lines (52 loc) · 2.04 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
name: Release
run-name: Release ${{ inputs.version || github.ref_name }}
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release. Must match VERSION and CHANGELOG.md.'
required: true
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read version from file
id: version
run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: Validate version
run: |
FILE_VERSION="$(cat VERSION)"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
RELEASE_VERSION="${{ inputs.version }}"
else
RELEASE_VERSION="${GITHUB_REF_NAME#v}"
fi
if [ "$RELEASE_VERSION" != "$FILE_VERSION" ]; then
echo "::error::Version mismatch: Input/Tag ($RELEASE_VERSION) != VERSION file ($FILE_VERSION)"
exit 1
fi
echo "Version validated: $FILE_VERSION"
- name: Validate changelog
run: |
FILE_VERSION="$(cat VERSION)"
VERSION_PATTERN="${FILE_VERSION//./\\.}"
if ! grep -Eq "^## \\[?v?${VERSION_PATTERN}\\]?" CHANGELOG.md; then
echo "::error::CHANGELOG.md must contain a release heading for $FILE_VERSION"
exit 1
fi
echo "Changelog entry found for $FILE_VERSION"
- name: Create Release
uses: whilesmart/workflows/go/release@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
binary_name: flatrun
build_path: ./cmd/flatrun
version: ${{ inputs.version || steps.version.outputs.version }}
platforms: '["linux/amd64", "linux/arm64", "darwin/amd64", "darwin/arm64"]'
ldflags: "-X github.com/flatrun/cli/internal/command.Version=${{ inputs.version || steps.version.outputs.version }} -X github.com/flatrun/cli/internal/command.BuildTime=$(date -u +%Y-%m-%d_%H:%M:%S) -X github.com/flatrun/cli/internal/command.GitCommit=${{ github.sha }}"