-
Notifications
You must be signed in to change notification settings - Fork 64
75 lines (74 loc) · 2.53 KB
/
release-and-publish.yml
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
name: Draft Release & Publish
on:
push:
branches:
- 'main'
paths:
- 'CHANGELOG.md'
jobs:
Release-Artifacts:
name: Draft Release
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
deployments: read
packages: none
steps:
# Checkout code
- name: Checkout
uses: actions/checkout@v4
# Read changelog and read versions etc.
- name: Check version is mentioned in Changelog.md
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
path: './CHANGELOG.md'
# Set the DRAFT_VERSION variable
- name: Set the draft version value and print other values.
run: |
echo "Version: ${{ steps.changelog_reader.outputs.version }}"
echo "Changes: ${{ steps.changelog_reader.outputs.changes }}"
echo "DRAFT_VERSION=${{ steps.changelog_reader.outputs.version }}" >> $GITHUB_ENV
# Make Release Dir
- name: Make Release Dir
run: mkdir bin
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
# Check if the newest tag already exists
- name: Check if tag exist
uses: mukunku/tag-exists-action@bdad1eaa119ce71b150b952c97351c75025c06a9 # v1.6.0
id: check-tag-exists
with:
tag: "v${{ steps.changelog_reader.outputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Build Binaries if this is a new release
- name: Build Draft Release Binaries
run: make build-all
if: ${{ steps.check-tag-exists.outputs.exists == 'false' }}
# If the tag already exists, we don't upload release artifacts
- name: Update Draft Release Body
if: ${{ steps.check-tag-exists.outputs.exists == 'true' }}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name : "v${{ steps.changelog_reader.outputs.version }}"
name: "v${{ steps.changelog_reader.outputs.version }}"
body: ${{ steps.changelog_reader.outputs.changes }}
# Create Release with artifacts
- name: Create Draft Release
if: ${{ steps.check-tag-exists.outputs.exists == 'false'}}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name : "v${{ steps.changelog_reader.outputs.version }}"
name: "v${{ steps.changelog_reader.outputs.version }}"
body: ${{ steps.changelog_reader.outputs.changes }}
files: |
./bin/*