-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 2.1 KB
/
release.yml
File metadata and controls
63 lines (53 loc) · 2.1 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
name: Go Release Builder
# This workflow runs whenever you push a tag that starts with 'v' (e.g., v1.0.0)
on:
push:
tags:
- 'v*'
jobs:
build-and-release:
# Use the latest Ubuntu environment for compilation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Step 1: Check out the repository code
- name: Checkout code
uses: actions/checkout@v4
- name: Add variables to environment file
run: cat ".github/env" >> "$GITHUB_ENV"
# Step 2: Set up the Go environment (adjust version if needed)
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true
# Step 3: Get the tag name from the context
- name: Get tag name
id: get_tag
run: echo "TAG=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
# Step 4: Compile the Go binary and inject the version
- name: Compile Go binary
# Set the GIT_TAG environment variable for the build command
env:
GIT_TAG: ${{ steps.get_tag.outputs.TAG }}
run: |
BINARY_NAME="vrsr"
# Run the build command as requested, using the injected tag name
go build -ldflags "-X github.com/stepbeta/vrsr/cmd.Version=$GIT_TAG" -o $BINARY_NAME
echo "Successfully compiled $BINARY_NAME with version $GIT_TAG"
# Step 5: Create the GitHub Release and upload the compiled binary
- name: Create GitHub Release
# Uses a popular action for creating releases
uses: softprops/action-gh-release@v1
with:
# Sets the name of the release in the UI
name: Release ${{ steps.get_tag.outputs.TAG }}
# The tag is already set by the trigger, but we ensure it's used
tag_name: ${{ steps.get_tag.outputs.TAG }}
# Define the files to upload as release assets
files: |
vrsr
env:
# GITHUB_TOKEN is automatically provided by GitHub Actions for authentication
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}