Skip to content
This repository was archived by the owner on Feb 9, 2025. It is now read-only.

Commit c4cd947

Browse files
committed
fix: Improve workflows with latest changes
1 parent aee5b3f commit c4cd947

File tree

2 files changed

+75
-16
lines changed

2 files changed

+75
-16
lines changed

.github/workflows/release-binaries.yaml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,58 @@ jobs:
3131
- goarch: arm64
3232
goos: windows
3333
steps:
34+
- id: read_tag
35+
name: Read release tag name (mostly vx.x.x)
36+
run: |
37+
if [ "${{ github.event_name }}" = "release" ]; then
38+
export TAG="${{ github.ref_name }}"
39+
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
40+
export TAG="${{ inputs.release }}"
41+
fi
42+
43+
echo "release_tag=${TAG}" >> "$GITHUB_OUTPUT"
44+
3445
- uses: actions/checkout@v3
46+
with:
47+
ref: ${{ steps.read_tag.outputs.release_tag }}
48+
49+
- name: Read Go version from go.mod
50+
id: read_go_version
51+
run: |
52+
go_version_raw=$(grep "^go " go.mod | awk '{print $2}')
53+
echo "go_version=${go_version_raw}" >> "$GITHUB_OUTPUT"
54+
55+
# Find the path for main.go file as recently golang project
56+
# structure was finally standardized
57+
- name: Determine main.go path
58+
id: find_main_go
59+
run: |
60+
if [ -f "./main.go" ]; then
61+
echo "main_go_path=./" >> "$GITHUB_OUTPUT"
62+
else
63+
echo "main_go_path=./cmd/" >> "$GITHUB_OUTPUT"
64+
fi
65+
66+
# Omit the LICENSE file only for the very first release.
67+
# This step is only to manage some technical debt we caused in the beginning.
68+
- name: Find release extra files
69+
id: find_release_extra_files
70+
run: |
71+
if [ -f "./LICENSE" ]; then
72+
echo "release_extra_files=LICENSE README.md" >> "$GITHUB_OUTPUT"
73+
else
74+
echo "release_extra_files=README.md" >> "$GITHUB_OUTPUT"
75+
fi
76+
3577
- uses: wangyoucao577/go-release-action@v1.31
3678
with:
3779
github_token: ${{ secrets.GITHUB_TOKEN }}
3880
goos: ${{ matrix.goos }}
3981
goarch: ${{ matrix.goarch }}
40-
goversion: "https://dl.google.com/go/go1.19.13.linux-amd64.tar.gz"
41-
project_path: "./"
82+
#goversion: "${{ steps.read_go_version.outputs.go_version }}"
83+
goversion: "https://dl.google.com/go/go${{ steps.read_go_version.outputs.go_version }}.linux-amd64.tar.gz"
84+
project_path: "${{ steps.find_main_go.outputs.main_go_path }}"
4285
binary_name: "rabbit-stalker"
4386
release_tag: ${{ inputs.release }}
4487
overwrite: true
45-
extra_files: LICENSE README.md
88+
extra_files: "${{ steps.find_release_extra_files.outputs.release_extra_files }}"

.github/workflows/release-bundle.yaml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,46 @@ jobs:
2020
name: Release Kubernetes manifests
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v3
24-
- uses: actions/setup-go@v5
25-
with:
26-
go-version: '1.19'
27-
check-latest: true
28-
- id: build
29-
name: Build TODO
23+
- id: read_tag
24+
name: Read release tag name (mostly vx.x.x)
3025
run: |
3126
if [ "${{ github.event_name }}" = "release" ]; then
3227
export TAG="${{ github.ref_name }}"
3328
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
3429
export TAG="${{ inputs.release }}"
3530
fi
36-
31+
3732
echo "release_tag=${TAG}" >> "$GITHUB_OUTPUT"
38-
39-
export IMG="ghcr.io/$GITHUB_REPOSITORY:$TAG"
33+
34+
- uses: actions/checkout@v3
35+
with:
36+
ref: ${{ steps.read_tag.outputs.release_tag }}
37+
38+
- name: Read Go version from go.mod
39+
id: read_go_version
40+
run: |
41+
go_version_raw=$(grep "^go " go.mod | awk '{print $2}')
42+
echo "go_version=${go_version_raw}" >> "$GITHUB_OUTPUT"
43+
44+
- uses: actions/setup-go@v5
45+
with:
46+
go-version: '${{ steps.read_go_version.outputs.go_version }}'
47+
check-latest: true
48+
49+
- id: build
50+
name: Build manifests bundle
51+
env:
52+
RELEASE_TAG: ${{ steps.read_tag.outputs.release_tag }}
53+
run: |
54+
export IMG="ghcr.io/$GITHUB_REPOSITORY:$RELEASE_TAG"
4055
make bundle-build
41-
- name: Release
56+
57+
- name: Attach bundle to the release
4258
uses: softprops/action-gh-release@v2
4359
env:
44-
RELEASE_TAG: ${{ steps.build.outputs.release_tag }}
60+
RELEASE_TAG: ${{ steps.read_tag.outputs.release_tag }}
4561
with:
46-
tag_name: ${{ steps.build.outputs.release_tag }}
62+
tag_name: ${{ steps.read_tag.outputs.release_tag }}
4763
body: ""
4864
files: |
4965
deploy/bundle.yaml

0 commit comments

Comments
 (0)