Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the version strategy similar to passwordless-server #66

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ 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: |
hash="${{ github.event.pull_request.head.sha || github.sha }}"
echo "version=0.0.0-ci-${hash:0:7}" >> $GITHUB_OUTPUT

outputs:
version: ${{ steps.stable-version.outputs.version || steps.pre-version.outputs.version }}

# Check formatting
format:
runs-on: ubuntu-latest
Expand All @@ -62,7 +84,6 @@ jobs:

strategy:
fail-fast: false
max-parallel: 3
matrix:
os: [ubuntu-latest, windows-latest]

Expand Down Expand Up @@ -95,6 +116,7 @@ jobs:

# Pack the output into NuGet packages
pack:
needs: version
runs-on: ubuntu-latest
permissions:
actions: write
Expand All @@ -117,29 +139,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
Expand Down Expand Up @@ -189,7 +196,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:
Expand All @@ -202,5 +212,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 }}"
}
Loading