Skip to content

Commit 67ee21c

Browse files
committed
ci: added github action to manage release
1 parent 870d550 commit 67ee21c

File tree

3 files changed

+72
-41
lines changed

3 files changed

+72
-41
lines changed

.github/workflows/docker.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Create and publish Docker images
33

44
on:
55
push:
6-
branches: ['trunk', 'main']
76

87
env:
98
REGISTRY: ghcr.io

.github/workflows/build.yaml renamed to .github/workflows/release.yaml

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
name: Build go binaries
2-
3-
on: push
1+
name: Build and Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- trunk
7+
pull_request:
8+
branches:
9+
- main
10+
- trunk
411

512
jobs:
613
build-stamusctl:
@@ -44,43 +51,48 @@ jobs:
4451
with:
4552
name: stamusd-${{matrix.os}}-${{matrix.arch}}
4653
path: dist/*
54+
release:
55+
name: Release
56+
needs: [build-stamusctl, build-stamusdaemon]
4757

48-
create-tag:
4958
runs-on: ${{ matrix.runner }}
50-
needs: [build-stamusctl, build-stamusdaemon]
5159
strategy:
5260
matrix:
5361
include:
5462
- { runner: ubuntu-latest, os: linux, arch: amd64, go-version: 1.22 }
5563

64+
# permissions:
65+
# contents: write # to be able to publish a GitHub release
66+
# issues: write # to be able to comment on released issues
67+
# pull-requests: write # to be able to comment on released pull requests
5668
steps:
57-
- name: Checkout repository
69+
- name: Checkout
5870
uses: actions/checkout@v4
59-
60-
- name: get tag version
61-
id: get_tag_version
62-
run: |
63-
cat VERSION
64-
echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
71+
with:
72+
fetch-depth: 0
73+
persist-credentials: false
6574

6675
- name: Download stamusctl
6776
uses: actions/download-artifact@v4
6877
with:
6978
name: stamusctl-${{matrix.os}}-${{matrix.arch}}
70-
7179
- name: Download stamusd
7280
uses: actions/download-artifact@v4
7381
with:
7482
name: stamusd-${{matrix.os}}-${{matrix.arch}}
7583

76-
- name: Release snapshot
77-
id: release-snapshot
78-
uses: softprops/action-gh-release@v2
79-
if: github.ref == 'refs/heads/main'
84+
- name: Setup Node.js
85+
uses: actions/setup-node@v4
8086
with:
81-
tag_name: ${{ steps.get_tag_version.outputs.version }}
82-
draft: false
83-
prerelease: false
84-
files: |
85-
stamusctl-${{matrix.os}}-${{matrix.arch}}
86-
stamusd-${{matrix.os}}-${{matrix.arch}}
87+
node-version: 'lts/*'
88+
- uses: pnpm/action-setup@v4
89+
- name: Install dependencies
90+
run: pnpm install
91+
92+
- name: Release
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.PUSH }}
95+
RUNNER: ${{ matrix.runner }}
96+
OS: ${{ matrix.os }}
97+
ARCH: ${{ matrix.arch }}
98+
run: pnpm run release --no-ci

release.config.js

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
const gitlab = [
2+
'@semantic-release/gitlab',
3+
{
4+
gitlabUrl: 'https://git.stamus-networks.com',
5+
assets: [
6+
{
7+
url: `${process.env.CI_API_V4_URL}/projects/${process.env.CI_PROJECT_ID}/packages/generic/stamusctl/${process.env.NEXT_VERSION}/stamusctl`,
8+
label: 'stamusctl',
9+
},
10+
{
11+
url: `${process.env.CI_API_V4_URL}/projects/${process.env.CI_PROJECT_ID}/packages/generic/stamusd/${process.env.NEXT_VERSION}/stamusctl`,
12+
label: 'stamusd',
13+
},
14+
],
15+
},
16+
]
17+
18+
const github = [
19+
'@semantic-release/github',
20+
{
21+
assets: [
22+
{
23+
path: `stamusctl-${process.env.OS}-${process.env.ARCH}`,
24+
label: `stamusctl (${process.env.OS?.toUpperCase()} ${process.env.ARCH?.toUpperCase()})`,
25+
},
26+
{
27+
path: `stamusd-${process.env.OS}-${process.env.ARCH}`,
28+
label: `stamusd (${process.env.OS?.toUpperCase()} ${process.env.ARCH?.toUpperCase()})`,
29+
},
30+
],
31+
},
32+
]
33+
34+
// Determine the CI environment
35+
const isGitLab = !!process.env.CI && !process.env.GITHUB_ACTIONS // GitLab CI sets CI, GitHub Actions sets GITHUB_ACTIONS
36+
137
/**
238
* @type {import('semantic-release').GlobalConfig}
339
*/
@@ -12,28 +48,12 @@ module.exports = {
1248
},
1349
],
1450
'@semantic-release/release-notes-generator',
15-
// '@semantic-release/changelog',
1651
[
1752
'@semantic-release/git',
1853
{
1954
message: 'ci(release): release ${nextRelease.version}\n\n${nextRelease.notes}',
2055
},
2156
],
22-
[
23-
'@semantic-release/gitlab',
24-
{
25-
gitlabUrl: 'https://git.stamus-networks.com',
26-
assets: [
27-
{
28-
url: `${process.env.CI_API_V4_URL}/projects/${process.env.CI_PROJECT_ID}/packages/generic/stamusctl/${process.env.NEXT_VERSION}/stamusctl`,
29-
label: 'stamusctl',
30-
},
31-
{
32-
url: `${process.env.CI_API_V4_URL}/projects/${process.env.CI_PROJECT_ID}/packages/generic/stamusd/${process.env.NEXT_VERSION}/stamusctl`,
33-
label: 'stamusd',
34-
},
35-
],
36-
},
37-
],
57+
...(isGitLab ? [gitlab] : [github]), // Dynamically select GitLab or GitHub
3858
],
3959
}

0 commit comments

Comments
 (0)