Skip to content

Commit 59c173a

Browse files
authored
Fix version handling in build workflow
1 parent 17e1bf6 commit 59c173a

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

.github/workflows/build_and_release_all.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
uses: actions/checkout@v4
5252
with:
5353
# If manually triggered, use the input branch; otherwise use the tag ref
54-
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.target_branch || github.ref_name }}
54+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref_name }}
5555

5656
- name: Setup .NET (8.x)
5757
uses: actions/setup-dotnet@v3
@@ -63,17 +63,17 @@ jobs:
6363
shell: bash
6464
run: |
6565
set -euo pipefail
66+
6667
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
6768
VERSION="0.0.1"
6869
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
69-
VERSION=${GITHUB_REF#refs/tags/}
70-
VERSION=${VERSION#release-v}
70+
VERSION="${GITHUB_REF#refs/tags/}"
71+
VERSION="${VERSION#release-v}"
7172
else
7273
VERSION="0.0.0-dev"
7374
fi
74-
echo "VERSION=$VERSION" >> $GITHUB_ENV
75-
76-
# NOTE: project paths changed — VERSION belongs with the desktop project now
75+
76+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
7777
echo "v$VERSION" > Companion.Desktop/VERSION
7878

7979
- name: Restore dependencies
@@ -108,6 +108,19 @@ jobs:
108108
-p:PublishSingleFile=true
109109
fi
110110
111+
- name: Write VERSION into publish output
112+
shell: bash
113+
run: |
114+
set -euo pipefail
115+
case "${{ runner.os }}" in
116+
Windows) PUBLISH_DIR="Companion.Desktop/bin/Release/net8.0/win-${{ matrix.arch }}/publish" ;;
117+
macOS) PUBLISH_DIR="Companion.Desktop/bin/Release/net8.0/osx-${{ matrix.arch }}/publish" ;;
118+
Linux) PUBLISH_DIR="Companion.Desktop/bin/Release/net8.0/linux-${{ matrix.arch }}/publish" ;;
119+
esac
120+
echo "v${{ env.VERSION }}" > "$PUBLISH_DIR/VERSION"
121+
echo "Wrote VERSION to $PUBLISH_DIR/VERSION:"
122+
cat "$PUBLISH_DIR/VERSION"
123+
111124
# ----- macOS: bundle .app + sign + dmg -----
112125
- name: Decode signing certificate
113126
if: matrix.os == 'macos-latest'

0 commit comments

Comments
 (0)