Skip to content

Commit b91005b

Browse files
authored
ci: job-level version extraction (#105)
1 parent 360c1d6 commit b91005b

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,8 @@ on:
66
- "v*"
77

88
jobs:
9-
get_version:
10-
name: Get Version
11-
runs-on: ubuntu-latest
12-
outputs:
13-
version: ${{ steps.version.outputs.version }}
14-
refname: ${{ steps.refname.outputs.refname }}
15-
steps:
16-
- id: version
17-
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
18-
- id: refname
19-
run: echo "refname=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
20-
219
publish_pypi:
2210
name: Publish to PyPI
23-
needs: get_version
2411
runs-on: ubuntu-latest
2512
environment:
2613
name: pypi
@@ -45,7 +32,6 @@ jobs:
4532

4633
publish_docker:
4734
name: Publish to Docker Hub
48-
needs: get_version
4935
runs-on: ubuntu-latest
5036
environment:
5137
name: dockerhub
@@ -54,6 +40,10 @@ jobs:
5440
- name: Checkout
5541
uses: actions/checkout@v5
5642

43+
- name: Set version
44+
id: version
45+
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
46+
5747
- name: Login to Docker Hub
5848
uses: docker/login-action@v3
5949
with:
@@ -73,11 +63,10 @@ jobs:
7363
push: true
7464
tags: |
7565
${{ vars.DOCKERHUB_USERNAME }}/torrra:latest
76-
${{ vars.DOCKERHUB_USERNAME }}/torrra:${{ needs.get_version.outputs.version }}
66+
${{ vars.DOCKERHUB_USERNAME }}/torrra:${{ steps.version.outputs.version }}
7767
7868
build_and_release_binaries:
7969
name: Build on ${{ matrix.os }}
80-
needs: get_version
8170
runs-on: ${{ matrix.os }}
8271
strategy:
8372
matrix:
@@ -109,43 +98,42 @@ jobs:
10998
ARCH=$(uname -m)
11099
111100
if [[ "$RUNNER_OS" == "Linux" ]]; then
112-
chmod +x dist/torrra
113-
cp dist/torrra "dist-out/torrra_${{ needs.get_version.outputs.refname }}_linux_${ARCH}"
101+
cp dist/torrra "dist-out/torrra_${GITHUB_REF_NAME}_linux_${ARCH}"
114102
elif [[ "$RUNNER_OS" == "Windows" ]]; then
115-
cp dist/torrra.exe "dist-out/torrra_${{ needs.get_version.outputs.refname }}_windows_${ARCH}.exe"
103+
cp dist/torrra.exe "dist-out/torrra_${GITHUB_REF_NAME}_windows_${ARCH}.exe"
116104
elif [[ "$RUNNER_OS" == "macOS" ]]; then
117-
chmod +x dist/torrra
118-
cp dist/torrra "dist-out/torrra_${{ needs.get_version.outputs.refname }}_macos_${ARCH}"
105+
cp dist/torrra "dist-out/torrra_${GITHUB_REF_NAME}_macos_${ARCH}"
119106
fi
120107
121108
- name: Upload binary to release
122109
uses: softprops/action-gh-release@v2
123110
with:
124111
files: dist-out/*
125-
token: ${{ secrets.GITHUB_TOKEN }}
126112

127113
publish_aur:
128114
name: Publish to AUR
129-
needs:
130-
- get_version
131-
- build_and_release_binaries
115+
needs: build_and_release_binaries
132116
runs-on: ubuntu-latest
133117
steps:
134118
- name: Checkout
135119
uses: actions/checkout@v5
136120

121+
- name: Set version
122+
id: version
123+
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
124+
137125
- name: Publish torrra to AUR
138126
uses: stabldev/aur-publish-action@v1
139127
with:
140128
pkgname: torrra
141-
pkgver: ${{ needs.get_version.outputs.version }}
129+
pkgver: ${{ steps.version.outputs.version }}
142130
pkgbuild_template: ./pkgbuild-template/torrra/PKGBUILD
143131
aur_ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
144132

145133
- name: Publish torrra-bin to AUR
146134
uses: stabldev/aur-publish-action@v1
147135
with:
148136
pkgname: torrra-bin
149-
pkgver: ${{ needs.get_version.outputs.version }}
137+
pkgver: ${{ steps.version.outputs.version }}
150138
pkgbuild_template: ./pkgbuild-template/torrra-bin/PKGBUILD
151139
aur_ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}

0 commit comments

Comments
 (0)