From 2f58688a7043a703798f7c8a81135556689dc885 Mon Sep 17 00:00:00 2001 From: Matheos Mattsson Date: Wed, 9 Jul 2025 21:54:26 +0300 Subject: [PATCH 1/2] Read major and minor versions from GH variables and use these and run_number to generate a version string and use it in dotnet publish and release and tagging --- .github/workflows/build-and-publish.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index d7c1527..a58b42a 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -25,6 +25,8 @@ jobs: rid: linux-x64 archive_name: SelectSight-Linux-x64.tar.gz publish_dir: publish/linux-x64 + outputs: + app_version: ${{ steps.generate_version.outputs.generated_version }} steps: - name: Checkout Repository @@ -38,8 +40,16 @@ jobs: - name: Restore Dependencies run: dotnet restore + - name: Generate Version Number + id: generate_version + shell: bash + run: | + VERSION_NUMBER="${{ vars.MAJOR_VERSION }}.${{ vars.MINOR_VERSION }}.${{ github.run_number }}" + echo "Generated version: $VERSION_NUMBER" + echo "generated_version=$VERSION_NUMBER" >> "$GITHUB_OUTPUT" + - name: Build and Publish for ${{ matrix.rid }} - run: dotnet publish ./SelectSight.csproj --configuration Release --no-restore --runtime ${{ matrix.rid }} --self-contained true -p:PublishSingleFile=true -p:DebugType=None -o ./publish/${{ matrix.rid }} + run: dotnet publish ./SelectSight.csproj --configuration Release --no-restore --runtime ${{ matrix.rid }} --self-contained true -p:PublishSingleFile=true -p:DebugType=None -o ./publish/${{ matrix.rid }} -p:Version=${{ steps.generate_version.outputs.generated_version }} - name: Archive published output (Windows) @@ -76,12 +86,13 @@ jobs: path: ./release_assets - name: Create Release - id: create_release uses: softprops/action-gh-release@v2 # Action to create a GitHub Release with: - tag_name: v${{ github.run_number }}-${{ github.run_id }} # Example: v123-456789 - name: Release ${{ github.run_number }} (${{ github.run_id }}) - body: Automated build for SelectSight + tag_name: v${{ needs.build.outputs.app_version }} + name: Release v${{ needs.build.outputs.app_version }} + body: | + Automated build for SelectSight + Version: ${{ needs.build.outputs.app_version }} draft: true files: | ./release_assets/SelectSight-Windows-x64.zip/SelectSight-Windows-x64.zip From ff747fcff67c2c2f62fac42ab14e31636eaeb821 Mon Sep 17 00:00:00 2001 From: Matheos Mattsson Date: Wed, 9 Jul 2025 22:14:35 +0300 Subject: [PATCH 2/2] Give version number in artifact name --- .github/workflows/build-and-publish.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index a58b42a..afe28e1 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -19,11 +19,9 @@ jobs: include: - os: windows-latest rid: win-x64 - archive_name: SelectSight-Windows-x64.zip publish_dir: publish/win-x64 - os: ubuntu-latest rid: linux-x64 - archive_name: SelectSight-Linux-x64.tar.gz publish_dir: publish/linux-x64 outputs: app_version: ${{ steps.generate_version.outputs.generated_version }} @@ -55,18 +53,24 @@ jobs: - name: Archive published output (Windows) if: ${{ matrix.os == 'windows-latest' }} shell: pwsh - run: Compress-Archive -Path ${{ matrix.publish_dir }}/* -DestinationPath ${{ matrix.archive_name }} + run: | + $ArchiveName = "SelectSight-Windows-x64-${{ steps.generate_version.outputs.generated_version }}.zip" + Compress-Archive -Path ${{ matrix.publish_dir }}/* -DestinationPath $ArchiveName + echo "archive_name=$ArchiveName" >> $env:GITHUB_ENV - name: Archive published output (Linux) if: ${{ matrix.os == 'ubuntu-latest' }} shell: bash - run: tar -czvf ${{ matrix.archive_name }} -C ${{ matrix.publish_dir }} . + run: | + ARCHIVE_NAME="SelectSight-Linux-x64-${{ steps.generate_version.outputs.generated_version }}.tar.gz" + tar -czvf "$ARCHIVE_NAME" -C ${{ matrix.publish_dir }} . + echo "archive_name=$ARCHIVE_NAME" >> "$GITHUB_ENV" - name: Upload Archived Artifact uses: actions/upload-artifact@v4 with: - name: ${{ matrix.archive_name }} - path: ./${{ matrix.archive_name }} + name: ${{ env.archive_name }} + path: ./${{ env.archive_name }} retention-days: 1 @@ -95,7 +99,7 @@ jobs: Version: ${{ needs.build.outputs.app_version }} draft: true files: | - ./release_assets/SelectSight-Windows-x64.zip/SelectSight-Windows-x64.zip - ./release_assets/SelectSight-Linux-x64.tar.gz/SelectSight-Linux-x64.tar.gz + ./release_assets/SelectSight-Windows-x64-${{ needs.build.outputs.app_version }}.zip/SelectSight-Windows-x64-${{ needs.build.outputs.app_version }}.zip + ./release_assets/SelectSight-Linux-x64-${{ needs.build.outputs.app_version }}.tar.gz/SelectSight-Linux-x64-${{ needs.build.outputs.app_version }}.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file