Skip to content

Commit 0725d8f

Browse files
authored
fix: build binaries with the correct version information (#550)
1 parent 2b00e3d commit 0725d8f

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

.github/workflows/build-binaries.yaml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
python_version:
1010
required: true
1111
type: string
12+
release_version:
13+
required: false
14+
type: string
1215

1316
jobs:
1417
build-binaries:
@@ -24,7 +27,8 @@ jobs:
2427
- name: Checkout source code
2528
uses: actions/checkout@v4
2629
with:
27-
fetch-depth: ${{ inputs.production_release == 'true' && '0' || '1' }}
30+
ref: ${{ inputs.release_version != '' && format('v{0}', inputs.release_version) || '' }}
31+
fetch-depth: 1
2832

2933
- name: Set up Python
3034
uses: actions/setup-python@v5
@@ -37,23 +41,12 @@ jobs:
3741
- name: Install dependencies
3842
run: poetry install --no-interaction
3943

40-
- name: Set release version
41-
shell: bash
42-
continue-on-error: true
43-
if: ${{ inputs.production_release == 'true' }}
44-
run: |
45-
echo "RELEASE_VERSION_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
46-
4744
- name: Configure build environment
4845
shell: bash
4946
run: |
5047
artifacts_dir="${{ github.workspace }}${{ runner.os == 'Windows' && '\dist\artifacts' || '/dist/artifacts' }}"
5148
mkdir -p $artifacts_dir
52-
if [ -n "${RELEASE_VERSION_TAG}" ]; then
53-
release_version="${RELEASE_VERSION_TAG:1}"
54-
package_name_version="-${release_version}"
55-
echo "RELEASE_VERSION=${release_version}" >> $GITHUB_ENV
56-
fi
49+
package_name_version="${{ inputs.release_version != '' && format('-{0}', inputs.release_version) || '' }}"
5750
package_name="algokit${package_name_version}-${{ runner.os }}_${{ runner.arch }}"
5851
echo "PACKAGE_NAME=`echo $package_name | tr '[:upper:]' '[:lower:]'`" >> $GITHUB_ENV
5952
echo "ARTIFACTS_DIR=${artifacts_dir}" >> $GITHUB_ENV
@@ -64,7 +57,7 @@ jobs:
6457
uses: ./.github/actions/build-binaries/windows
6558
with:
6659
package_name: ${{ env.PACKAGE_NAME }}
67-
version: ${{ env.RELEASE_VERSION }}
60+
version: ${{ inputs.release_version }}
6861
artifacts_dir: ${{ env.ARTIFACTS_DIR }}
6962
production_release: ${{ inputs.production_release }}
7063
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
@@ -76,15 +69,15 @@ jobs:
7669
uses: ./.github/actions/build-binaries/linux
7770
with:
7871
package_name: ${{ env.PACKAGE_NAME }}
79-
version: ${{ env.RELEASE_VERSION }}
72+
version: ${{ inputs.release_version }}
8073
artifacts_dir: ${{ env.ARTIFACTS_DIR }}
8174

8275
- name: Build macOS binary
8376
if: ${{ runner.os == 'macOS' }}
8477
uses: ./.github/actions/build-binaries/macos
8578
with:
8679
package_name: ${{ env.PACKAGE_NAME }}
87-
version: ${{ env.RELEASE_VERSION }}
80+
version: ${{ inputs.release_version }}
8881
artifacts_dir: ${{ env.ARTIFACTS_DIR }}
8982

9083
- name: Add binary to path
@@ -121,5 +114,5 @@ jobs:
121114
fail_on_unmatched_files: true
122115
files: |
123116
${{ env.ARTIFACTS_DIR }}/*.*
124-
tag_name: ${{ env.RELEASE_VERSION_TAG }}
125-
prerelease: ${{ contains(env.RELEASE_VERSION_TAG, 'beta') }}
117+
tag_name: ${{ format('v{0}', inputs.release_version) }}
118+
prerelease: ${{ contains(inputs.release_version, 'beta') }}

.github/workflows/cd.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ jobs:
3636
name: Release wheels to pypi
3737
needs: ci-build-python
3838
runs-on: ubuntu-latest
39-
39+
outputs:
40+
release_version: ${{ steps.get_release_version.outputs.RELEASE_VERSION }}
4041
steps:
4142
- uses: actions/checkout@v4
4243
with:
@@ -72,8 +73,9 @@ jobs:
7273
--define=prerelease_tag=beta+${{ steps.get_branch.outputs.branch }} \
7374
--define=branch=${{ steps.get_branch.outputs.branch }} \
7475
publish
75-
gh release edit --prerelease "$(git describe $(git rev-list --tags --max-count=1))"
76-
# --define=upload_to_repository=true \
76+
release_version_tag="$(git describe $(git rev-list --tags --max-count=1))"
77+
gh release edit --prerelease $release_version_tag
78+
echo "RELEASE_VERSION=${release_version_tag:1}" >> $GITHUB_ENV
7779
env:
7880
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7981
REPOSITORY_USERNAME: __token__
@@ -87,8 +89,9 @@ jobs:
8789
--prerelease \
8890
--define=branch=main \
8991
publish
90-
gh release edit --prerelease "v$(poetry run semantic-release print-version --current)"
91-
# --define=upload_to_repository=true \
92+
release_version="$(poetry run semantic-release print-version --current)"
93+
gh release edit --prerelease "v$release_version"
94+
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
9295
env:
9396
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9497
REPOSITORY_USERNAME: __token__
@@ -104,11 +107,18 @@ jobs:
104107
--define=upload_to_repository=true \
105108
--define=branch=main \
106109
publish
110+
release_version="$(poetry run semantic-release print-version --current)"
111+
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
107112
env:
108113
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109114
REPOSITORY_USERNAME: __token__
110115
REPOSITORY_PASSWORD: ${{ secrets.PYPI_API_KEY }}
111116

117+
- name: Get release version
118+
shell: bash
119+
run: echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
120+
id: get_release_version
121+
112122
- name: Upload artifact
113123
uses: actions/upload-artifact@v4
114124
with:
@@ -122,8 +132,9 @@ jobs:
122132
uses: ./.github/workflows/build-binaries.yaml
123133
needs: release
124134
with:
125-
production_release: "true"
135+
production_release: ${{ inputs.production_release }}
126136
python_version: "3.12"
137+
release_version: ${{ needs.release.outputs.release_version }}
127138
secrets: inherit
128139

129140
cd-publish-release-packages:

scripts/winget/build-installer.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $version = if ($releaseVersion) {
3838
else {
3939
'0.0.1'
4040
}
41-
(Get-Content (Resolve-Path "$installerContentDir\AppxManifest.xml")).Replace('0.0.1.0', $("$version.0")) | Set-Content (Join-Path $buildDir AppxManifest.xml)
41+
(Get-Content (Resolve-Path "$installerContentDir\AppxManifest.xml")).Replace('"0.0.1.0"', "`"$version.0`"") | Set-Content (Join-Path $buildDir AppxManifest.xml)
4242

4343
# Generate pri resource map for installer assets
4444
$priConfig = (Resolve-Path "$installerContentDir\priconfig.xml")

scripts/winget/installer/priconfig.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@
2525
<indexer-config type="resjson" initialPath=""/>
2626
<indexer-config type="PRI"/>
2727
</index>
28-
<!--<index startIndexAt="Start Index Here" root="Root Here">-->
29-
<!-- <indexer-config type="resfiles" qualifierDelimiter="."/>-->
30-
<!-- <indexer-config type="priinfo" emitStrings="true" emitPaths="true" emitEmbeddedData="true"/>-->
31-
<!--</index>-->
3228
</resources>

0 commit comments

Comments
 (0)