Skip to content

Commit dfd795c

Browse files
committed
chore: release action
1 parent f884ba8 commit dfd795c

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
# the intention here is to always have a release (automated)
4+
# but this workflow can be triggered from a workflow in nuonco/nuon
5+
6+
on:
7+
workflow_dispatch:
8+
schedule:
9+
# Check daily at 06:00 UTC for a new API version
10+
- cron: "0 6 * * *"
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
27+
- name: Get API version
28+
id: version
29+
run: |
30+
API_VERSION=$(curl -sS https://api.nuon.co/version | jq -r '.version')
31+
echo "api_version=$API_VERSION" >> "$GITHUB_OUTPUT"
32+
echo "tag=v$API_VERSION" >> "$GITHUB_OUTPUT"
33+
echo "API version: $API_VERSION"
34+
35+
- name: Check if release already exists
36+
id: check
37+
run: |
38+
TAG="${{ steps.version.outputs.tag }}"
39+
if gh release view "$TAG" >/dev/null 2>&1; then
40+
echo "exists=true" >> "$GITHUB_OUTPUT"
41+
echo "Release $TAG already exists, skipping."
42+
else
43+
echo "exists=false" >> "$GITHUB_OUTPUT"
44+
echo "Release $TAG does not exist, proceeding."
45+
fi
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Download latest spec
50+
if: steps.check.outputs.exists == 'false'
51+
run: curl -sS https://api.nuon.co/docs/doc.json -o spec/doc.json
52+
53+
- name: Run GoReleaser
54+
if: steps.check.outputs.exists == 'false'
55+
uses: goreleaser/goreleaser-action@v6
56+
with:
57+
version: latest
58+
args: release --clean
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.tag }}

0 commit comments

Comments
 (0)