Skip to content

Commit 858fd3b

Browse files
committed
fix: refactor GitHub Actions workflow for clarity and consistency
1 parent e20b4a9 commit 858fd3b

File tree

1 file changed

+26
-34
lines changed

1 file changed

+26
-34
lines changed

.github/workflows/release.yml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ name: Release
22

33
on:
44
push:
5-
tags:
6-
- 'v*' # e.g. v1.0.0, v2.1.3
75
branches:
86
- main
7+
tags:
8+
- 'v*'
99

1010
permissions:
11-
contents: write # allows creating releases + uploading assets
11+
# Allow creating releases and uploading assets
12+
contents: write
1213

1314
jobs:
14-
# ────────────────────────────────────────────────────────────────────────
15-
# 1. CREATE RELEASE (runs only once)
16-
# ────────────────────────────────────────────────────────────────────────
17-
create_release:
15+
# ───────────────────────────────────────────────────────────────────────────
16+
# 1. Create the GitHub Release (runs once per tag push)
17+
# ───────────────────────────────────────────────────────────────────────────
18+
create:
1819
name: Create GitHub Release
1920
runs-on: ubuntu-latest
2021
steps:
@@ -27,17 +28,17 @@ jobs:
2728
env:
2829
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2930
with:
30-
tag_name: ${{ github.ref_name }}
31-
release_name: Release ${{ github.ref_name }}
32-
draft: false
33-
prerelease: false
31+
tag_name: ${{ github.ref_name }}
32+
release_name: ${{ github.ref_name }}
33+
draft: false
34+
prerelease: false
3435

35-
# ────────────────────────────────────────────────────────────────────────
36-
# 2. BUILD & UPLOAD ASSETS (matrix)
37-
# ────────────────────────────────────────────────────────────────────────
38-
build_and_upload:
36+
# ───────────────────────────────────────────────────────────────────────────
37+
# 2. Build & Upload Assets (matrix)
38+
# ───────────────────────────────────────────────────────────────────────────
39+
build:
3940
name: Build & Upload Assets
40-
needs: create_release
41+
needs: create
4142
runs-on: ${{ matrix.os }}
4243
strategy:
4344
matrix:
@@ -70,37 +71,28 @@ jobs:
7071
- name: Copy & rename binary
7172
run: |
7273
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
73-
cp "target\\${{ matrix.target }}\\release\\mytool${{ matrix.ext }}" "dist/mytool-${{ matrix.target }}${{ matrix.ext }}"
74+
cp "target\\${{ matrix.target }}\\release\\favis${{ matrix.ext }}" "dist/favis-${{ matrix.target }}${{ matrix.ext }}"
7475
else
75-
cp target/${{ matrix.target }}/release/mytool${{ matrix.ext }} dist/mytool-${{ matrix.target }}${{ matrix.ext }}
76+
cp target/${{ matrix.target }}/release/favis${{ matrix.ext }} dist/favis-${{ matrix.target }}${{ matrix.ext }}
7677
fi
7778
7879
- name: Generate SHA256 checksum
7980
working-directory: dist
8081
shell: bash
81-
run: |
82-
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
83-
powershell -Command "Get-FileHash -Algorithm SHA256 mytool-${{ matrix.target }}${{ matrix.ext }} | ForEach-Object { \"$($_.Hash) *mytool-${{ matrix.target }}${{ matrix.ext }}\" } | Out-File -Encoding utf8 mytool-${{ matrix.target }}${{ matrix.ext }}.sha256"
84-
else
85-
sha256sum mytool-${{ matrix.target }}${{ matrix.ext }} > mytool-${{ matrix.target }}${{ matrix.ext }}.sha256
86-
fi
82+
run: sha256sum favis-${{ matrix.target }}${{ matrix.ext }} > favis-${{ matrix.target }}${{ matrix.ext }}.sha256
8783

8884
- name: Upload binary asset
8985
uses: actions/upload-release-asset@v1
90-
env:
91-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9286
with:
93-
upload_url: ${{ needs.create.outputs.upload_url }}
94-
asset_path: dist/mytool-${{ matrix.target }}${{ matrix.ext }}
95-
asset_name: mytool-${{ matrix.target }}${{ matrix.ext }}
87+
upload_url: ${{ needs.create.outputs.upload_url }}
88+
asset_path: dist/favis-${{ matrix.target }}${{ matrix.ext }}
89+
asset_name: favis-${{ matrix.target }}${{ matrix.ext }}
9690
asset_content_type: application/octet-stream
9791

9892
- name: Upload checksum asset
9993
uses: actions/upload-release-asset@v1
100-
env:
101-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10294
with:
103-
upload_url: ${{ needs.create.outputs.upload_url }}
104-
asset_path: dist/mytool-${{ matrix.target }}${{ matrix.ext }}.sha256
105-
asset_name: mytool-${{ matrix.target }}${{ matrix.ext }}.sha256
95+
upload_url: ${{ needs.create.outputs.upload_url }}
96+
asset_path: dist/favis-${{ matrix.target }}${{ matrix.ext }}.sha256
97+
asset_name: favis-${{ matrix.target }}${{ matrix.ext }}.sha256
10698
asset_content_type: text/plain

0 commit comments

Comments
 (0)