From 2b6c889717c91792338e85836cae99685aa31ccf Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Wed, 1 Nov 2023 19:01:30 +0200 Subject: [PATCH] Make the version strategy similar to passwordless-server --- .github/workflows/main.yml | 48 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f67fdd3..87dc075 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,26 @@ env: # steps to more sensitive access scopes. jobs: + # Determine version + version: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Determine stable version + id: stable-version + if: ${{ github.event_name == 'release' }} + run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT + + - name: Determine prerelease version + id: pre-version + if: ${{ github.event_name != 'release' }} + run: echo "version=0.0.0-ci-${{ github.event.pull_request.head.sha || github.sha }}" >> $GITHUB_OUTPUT + + outputs: + version: ${{ steps.stable-version.outputs.version || steps.pre-version.outputs.version }} + # Check formatting format: runs-on: ubuntu-latest @@ -62,7 +82,6 @@ jobs: strategy: fail-fast: false - max-parallel: 3 matrix: os: [ubuntu-latest, windows-latest] @@ -95,6 +114,7 @@ jobs: # Pack the output into NuGet packages pack: + needs: version runs-on: ubuntu-latest permissions: actions: write @@ -117,29 +137,14 @@ jobs: --configuration Release -p:ContinuousIntegrationBuild=true - # When triggered by `push` or `pull_request` events, generate a prerelease version - # for the packages, so as to clearly indicate that it's not a stable version release. - - name: Generate prerelease version - id: prerelease-version - if: ${{ github.event_name != 'release' }} - run: | - time=$(date +%s) - ref="${{ github.head_ref || github.ref_name }}" - - ref_clean=$ref - ref_clean="${ref_clean/\//-}" - ref_clean="${ref_clean/_/-}" - - echo "version=0.0.0-ci-$time-$ref_clean" >> $GITHUB_OUTPUT - - name: Create packages run: > dotnet pack + -p:Version=${{ needs.version.outputs.version }} + -p:ContinuousIntegrationBuild=true --no-restore --no-build --configuration Release - -p:ContinuousIntegrationBuild=true - ${{ steps.prerelease-version.outputs.version && format('-p:Version={0}', steps.prerelease-version.outputs.version) || '' }} - name: Upload artifacts uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 @@ -189,7 +194,10 @@ jobs: # Notify the Slack channel about the release notify: if: ${{ github.event_name == 'release' }} - needs: deploy + needs: + - version + - deploy + runs-on: ubuntu-latest steps: @@ -202,5 +210,5 @@ jobs: Content-Type: application/json; charset=UTF-8 body: | { - "text": "*Passwordless-dotnet* version `${{ github.event.release.name }}` has been released! 🎉\nDetails: ${{ github.event.release.html_url }}" + "text": "*Passwordless-dotnet* version `${{ needs.version.outputs.version }}` has been released! 🎉\nDetails: ${{ github.event.release.html_url }}" }