Skip to content

Commit c3bbf0b

Browse files
authored
Add workflow to create release (#1)
Signed-off-by: Sean Sundberg <seansund@us.ibm.com>
1 parent c6dd15d commit c3bbf0b

6 files changed

Lines changed: 141 additions & 26 deletions

File tree

.env

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/release-drafter.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
4+
categories:
5+
- title: 'Features'
6+
labels:
7+
- 'feature'
8+
- 'enhancement'
9+
- title: 'Bug Fixes'
10+
labels:
11+
- 'fix'
12+
- 'bugfix'
13+
- 'bug'
14+
- title: 'Maintenance'
15+
label: 'chore'
16+
version-resolver:
17+
major:
18+
labels:
19+
- 'major'
20+
minor:
21+
labels:
22+
- 'minor'
23+
patch:
24+
labels:
25+
- 'patch'
26+
default: patch
27+
template: |
28+
$CHANGES
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Library build
2+
3+
# Controls when the workflow will run
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '^1.24.5' # The Go version to download (if necessary) and use.
21+
22+
- name: Build code
23+
run: |
24+
make build
25+
26+
- name: Test code
27+
run: |
28+
make test

.github/workflows/release.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release module
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the main branch
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
# Steps represent a sequence of tasks that will be executed as part of the job
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
# Drafts your next Release notes as Pull Requests are merged into "main"
20+
- name: Create release
21+
id: create-release
22+
uses: release-drafter/release-drafter@v6
23+
with:
24+
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
25+
config-name: release-drafter.yaml
26+
publish: false
27+
prerelease: false
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: '^1.24.5' # The Go version to download (if necessary) and use.
35+
36+
- name: Update version
37+
run: |
38+
TAG_NAME=$(echo "${{ steps.create-release.outputs.tag_name }}" | sed "s/v//g")
39+
cat Makefile | sed "s/^VERSION .*/VERSION ?= ${TAG_NAME}/g" > /tmp/Makefile
40+
diff Makefile /tmp/Makefile && echo "" || echo ""
41+
cp /tmp/Makefile Makefile
42+
43+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
44+
git config --local user.name "github-actions[bot]"
45+
46+
git add -u
47+
48+
git commit -m "Update version to ${TAG_NAME} Makefile"
49+
50+
- name: Push changes
51+
uses: ad-m/github-push-action@master
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Publish release
56+
id: publish-release
57+
uses: eregon/publish-release@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
60+
with:
61+
release_id: ${{ steps.create-release.outputs.id }}

Makefile

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
include .env
1+
# Environment variables for the build process
2+
3+
PROJECTNAME=go-collections
4+
5+
MODULE=github.com/cloud-native-toolkit/go-collections
6+
7+
# Go related variables.
8+
GOBASE=$(shell pwd)
9+
GOPATH=$(GOBASE)/vendor:$(GOBASE) # You can remove or change the path after last colon.
10+
GOBIN=$(GOBASE)/bin
11+
GOFILES=$(wildcard *.go)
12+
GOTESTS=$(shell find . -name "*_test.go" | grep -v vendor | xargs -I{} dirname {} | sed -E "s~[.]~${MODULE}~g")
13+
VERSION ?= v0.0.0
14+
15+
# Redirect error output to a file, so we can show it in development mode.
16+
STDERR=/tmp/.$(PROJECTNAME)-stderr.txt
17+
18+
# PID file will store the server process id when it's running on development mode
19+
PID=/tmp/.$(PROJECTNAME)-api-server.pid
20+
21+
# Make is verbose in Linux. Make it silent.
22+
MAKEFLAGS += --silent
23+
224

325
go-compile: go-clean go-get go-build
426

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/cloud-native-toolkit/go-collections
22

3-
go 1.23.0
4-
5-
toolchain go1.24.4
3+
go 1.24.5
64

75
require (
86
github.com/onsi/ginkgo/v2 v2.23.4

0 commit comments

Comments
 (0)