Skip to content

Commit 9414f25

Browse files
author
privapps
committed
initial commit
1 parent 05c4f07 commit 9414f25

File tree

13 files changed

+1799
-201
lines changed

13 files changed

+1799
-201
lines changed

.github/workflows/release.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.version.outputs.version }}
16+
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v4
25+
with:
26+
go-version: '1.21'
27+
28+
- name: Get next version
29+
id: version
30+
run: |
31+
# Get the latest tag, if no tags exist, start with v0.0.0
32+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
33+
echo "Latest tag: $LATEST_TAG"
34+
35+
# Extract version numbers
36+
VERSION=${LATEST_TAG#v}
37+
IFS='.' read -r -a VERSION_PARTS <<< "$VERSION"
38+
MAJOR=${VERSION_PARTS[0]:-0}
39+
MINOR=${VERSION_PARTS[1]:-0}
40+
PATCH=${VERSION_PARTS[2]:-0}
41+
42+
# Increment patch version
43+
PATCH=$((PATCH + 1))
44+
45+
# If this is the first release and we're starting from v0.0.0, set to v0.0.1
46+
if [ "$LATEST_TAG" = "v0.0.0" ]; then
47+
NEW_VERSION="v0.0.1"
48+
else
49+
NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
50+
fi
51+
52+
echo "New version: $NEW_VERSION"
53+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
54+
55+
- name: Create and push tag
56+
run: |
57+
git config user.name "github-actions[bot]"
58+
git config user.email "github-actions[bot]@users.noreply.github.com"
59+
git tag ${{ steps.version.outputs.version }}
60+
git push origin ${{ steps.version.outputs.version }}
61+
62+
- name: Create Release
63+
id: create_release
64+
uses: actions/create-release@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
tag_name: ${{ steps.version.outputs.version }}
69+
release_name: Release ${{ steps.version.outputs.version }}
70+
body: |
71+
## Changes in ${{ steps.version.outputs.version }}
72+
73+
Auto-generated release from main branch.
74+
75+
### Downloads
76+
- Linux AMD64: `github-copilot-svcs-linux-amd64`
77+
- Linux ARM64: `github-copilot-svcs-linux-arm64`
78+
- macOS AMD64: `github-copilot-svcs-darwin-amd64`
79+
- macOS ARM64: `github-copilot-svcs-darwin-arm64`
80+
- Windows AMD64: `github-copilot-svcs-windows-amd64.exe`
81+
- Windows ARM64: `github-copilot-svcs-windows-arm64.exe`
82+
draft: false
83+
prerelease: false
84+
85+
build:
86+
needs: release
87+
runs-on: ubuntu-latest
88+
strategy:
89+
matrix:
90+
include:
91+
- goos: linux
92+
goarch: amd64
93+
suffix: ""
94+
- goos: linux
95+
goarch: arm64
96+
suffix: ""
97+
- goos: darwin
98+
goarch: amd64
99+
suffix: ""
100+
- goos: darwin
101+
goarch: arm64
102+
suffix: ""
103+
- goos: windows
104+
goarch: amd64
105+
suffix: ".exe"
106+
- goos: windows
107+
goarch: arm64
108+
suffix: ".exe"
109+
110+
steps:
111+
- name: Checkout code
112+
uses: actions/checkout@v4
113+
114+
- name: Set up Go
115+
uses: actions/setup-go@v4
116+
with:
117+
go-version: '1.21'
118+
119+
- name: Build binary
120+
env:
121+
GOOS: ${{ matrix.goos }}
122+
GOARCH: ${{ matrix.goarch }}
123+
CGO_ENABLED: 0
124+
run: |
125+
BINARY_NAME="github-copilot-svcs-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
126+
go build -ldflags="-s -w -X main.version=${{ needs.release.outputs.version }}" -o "$BINARY_NAME" .
127+
128+
# Make the binary executable (important for Unix systems)
129+
chmod +x "$BINARY_NAME"
130+
131+
echo "Built binary: $BINARY_NAME"
132+
ls -la "$BINARY_NAME"
133+
134+
- name: Upload Release Asset
135+
uses: actions/upload-release-asset@v1
136+
env:
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
with:
139+
upload_url: ${{ needs.release.outputs.upload_url }}
140+
asset_path: ./github-copilot-svcs-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}
141+
asset_name: github-copilot-svcs-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}
142+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)