Use date + run number for nightly package versions #169
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Package | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| # NOTE: uSync releases from "v{major}/main" - a branch per Umbraco major. Plain "main" | |
| # is kept in the filter so a re-created main, or a branch that hasn't been moved over | |
| # yet, still builds. | |
| on: | |
| push: | |
| branches: [ "main", "*/main" ] | |
| paths-ignore: | |
| - "**.md" | |
| - "docs/**" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| config: Release | |
| out_folder: ./build-out/ | |
| solution_name: ./uSync.slnx | |
| test_project: ./uSync.Tests/uSync.Tests.csproj | |
| schema_gen_project: ./uSync.SchemaGenerator/uSync.SchemaGenerator.csproj | |
| jobs: | |
| version: | |
| runs-on: windows-latest | |
| outputs: | |
| # These builds are only ever pushed to the Azure Artifacts nightly feed, never | |
| # to nuget.org, so the version carries a date + run number rather than | |
| # GitVersion's own prerelease scheme - makes it obvious which nightly a given | |
| # package build is, and when it was built. | |
| version_string: ${{ steps.gitversion.outputs.majorMinorPatch }}-build.${{ steps.nightly_date.outputs.date }}.${{ github.run_number }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install GitVersion | |
| # pinned to v3 on purpose: v4 of this action requires GitVersion >= 6.2, and our | |
| # GitVersion.yml is still v5 schema (mode / tag rather than deployment-mode / label). | |
| # Moving to v4 means migrating that config too - see the dependabot ignore. | |
| uses: gittools/actions/gitversion/setup@v3 | |
| with: | |
| versionSpec: "5.x" | |
| - name: Determine Version with GitVersion (MSBuild in Proj will do this) | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v3 | |
| with: | |
| useConfigFile: true | |
| configFilePath: ./GitVersion.yml | |
| - name: Determine build date | |
| id: nightly_date | |
| shell: bash | |
| run: echo "date=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT" | |
| - name: Display version | |
| run: | | |
| echo "Full Version: ${{ steps.gitversion.outputs.majorMinorPatch }}-build.${{ steps.nightly_date.outputs.date }}.${{ github.run_number }}" | |
| build-project: | |
| runs-on: windows-latest | |
| needs: version | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-dotnet@v6 | |
| with: | |
| global-json-file: global.json | |
| cache: true | |
| cache-dependency-path: "**/packages.lock.json" | |
| # the client project's build runs `npm run build` via an MSBuild target, | |
| # so node needs to be available before the dotnet build step below. | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: "lts/*" | |
| cache: npm | |
| cache-dependency-path: ./uSync.Backoffice.Management.Client/usync-assets/package-lock.json | |
| - name: restore | |
| run: dotnet restore ${{ env.solution_name }} --locked-mode | |
| - name: build | |
| run: dotnet build ${{ env.solution_name }} -c ${{ env.config }} -p:ContinuousIntegrationBuild=true | |
| - name: test | |
| run: dotnet test ${{ env.test_project }} -c ${{ env.config }} | |
| - name: Generate AppSettings Schema | |
| run: dotnet run -c ${{ env.config }} --project ${{ env.schema_gen_project }} | |
| package-up: | |
| runs-on: windows-latest | |
| needs: [build-project, version] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-dotnet@v6 | |
| with: | |
| global-json-file: global.json | |
| cache: true | |
| cache-dependency-path: "**/packages.lock.json" | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: "lts/*" | |
| cache: npm | |
| cache-dependency-path: ./uSync.Backoffice.Management.Client/usync-assets/package-lock.json | |
| - name: version | |
| run: | | |
| echo "Version: ${{ needs.version.outputs.version_string}}" | |
| - name: Stamp version on NPM Package | |
| working-directory: ./uSync.Backoffice.Management.Client/usync-assets | |
| run: npm version ${{ needs.version.outputs.version_string }} | |
| - name: npm install | |
| working-directory: ./uSync.Backoffice.Management.Client/usync-assets | |
| run: npm ci | |
| - name: npm build | |
| working-directory: ./uSync.Backoffice.Management.Client/usync-assets | |
| run: npm run build | |
| - name: restore | |
| run: dotnet restore ${{ env.solution_name }} --locked-mode | |
| - name: package uSync.Core | |
| run: dotnet pack ./uSync.Core/uSync.Core.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.AutoTemplates | |
| run: dotnet pack ./uSync.AutoTemplates/uSync.AutoTemplates.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.BackOffice | |
| run: dotnet pack ./uSync.BackOffice/uSync.BackOffice.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.Backoffice.Management.Api | |
| run: dotnet pack ./uSync.Backoffice.Management.Api/uSync.Backoffice.Management.Api.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.Backoffice.Management.Client | |
| run: dotnet pack ./uSync.Backoffice.Management.Client/uSync.Backoffice.Management.Client.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.BackOffice.Targets | |
| run: dotnet pack ./uSync.BackOffice.Targets/uSync.BackOffice.Targets.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.Community.Contrib | |
| run: dotnet pack ./uSync.Community.Contrib/uSync.Community.Contrib.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.Community.DataTypeSerializers | |
| run: dotnet pack ./uSync.Community.DataTypeSerializers/uSync.Community.DataTypeSerializers.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.Extend | |
| run: dotnet pack ./uSync.Extend/uSync.Extend.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync.History | |
| run: dotnet pack ./uSync.History/uSync.History.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| - name: package uSync (meta package) | |
| run: dotnet pack ./uSync/uSync.csproj -c ${{env.config}} --output ${{env.out_folder}} /p:version=${{ needs.version.outputs.version_string }} | |
| # NOTE: this workflow builds artifacts on every push to a release branch for | |
| # review. Full releases to nuget.org happen separately, in release.yml, | |
| # triggered by pushing a v{version} tag. The publish-nightly job below pushes | |
| # these same build-every-commit packages to the Azure Artifacts nightly feed | |
| # instead, so testers can track main without waiting for a tagged release. | |
| - name: Upload nuget file as build artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: Nuget Build Output | |
| path: ${{ env.out_folder }} | |
| publish-nightly: | |
| runs-on: windows-latest | |
| needs: package-up | |
| # Nightly feed is only fed from the current active major version branch. | |
| if: github.ref == 'refs/heads/v18/main' | |
| env: | |
| nightly_source: https://pkgs.dev.azure.com/jumoo/Public/_packaging/nightly/nuget/v3/index.json | |
| steps: | |
| - name: Download nuget build artifact | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: Nuget Build Output | |
| path: ${{ env.out_folder }} | |
| # Azure Artifacts doesn't accept a bare API key for push auth - the PAT has to | |
| # go on the source itself as the password of a basic-auth credential. | |
| - name: Add Azure Artifacts nightly feed as a nuget source | |
| run: > | |
| dotnet nuget add source ${{ env.nightly_source }} | |
| --name AzureArtifactsNightly | |
| --username jumoo | |
| --password ${{ secrets.AZURE_ARTIFACTS_PAT }} | |
| --store-password-in-clear-text | |
| # --skip-duplicate so re-running this workflow for a version already on the | |
| # nightly feed is a no-op rather than a failure. | |
| # | |
| # `dotnet nuget push "<dir>/*.nupkg"` does not reliably glob-expand on this | |
| # runner, so the .nupkg files are enumerated explicitly instead. | |
| - name: push to Azure Artifacts nightly feed | |
| run: | | |
| Get-ChildItem -Path "${{ env.out_folder }}" -Filter *.nupkg | ForEach-Object { | |
| dotnet nuget push $_.FullName --api-key az --source AzureArtifactsNightly --skip-duplicate | |
| } |