Skip to content
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
29 changes: 25 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,27 @@ jobs:

- name: Determine Version
id: git-version
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]
then
echo "::set-output name=nuGetVersion::${GITVERSION_MAJORMINORPATCH}-nightly-${{ github.run_number }}"
echo "Version: ${GITVERSION_MAJORMINORPATCH}-nightly-${{ github.run_number }}"
VERSION="${GITVERSION_MAJORMINORPATCH}-nightly-${{ github.run_number }}"
elif [ "${{ github.event_name }}" == "pull_request" ]
then
# GitVersion numbers a PR build from the commit count, so amending a commit reuses the
# number and the package collides with the one already in Octopus. Appending the head
# SHA gives every commit its own package and records which commit produced it. The
# count stays in front so builds still sort in order - Octopus compares that identifier
# numerically, ranking .10 above .5. The `g` prefix, as in `git describe`, keeps the
# identifier alphanumeric: an all-digit SHA beginning with a zero would be an invalid
# SemVer numeric identifier.
VERSION="${GITVERSION_FULLSEMVER}.g${PR_HEAD_SHA:0:7}"
else
echo "::set-output name=nuGetVersion::${GITVERSION_FULLSEMVER}"
echo "Version: ${GITVERSION_FULLSEMVER}"
VERSION="${GITVERSION_FULLSEMVER}"
fi
echo "::set-output name=nuGetVersion::${VERSION}"
echo "Version: ${VERSION}"

- name: Build with gradle
run: ./gradlew build test -Pversion=${{ steps.git-version.outputs.nugetVersion }}
Expand Down Expand Up @@ -170,11 +182,16 @@ jobs:
with:
packages: 'Octopus.TeamCity'
version: ${{ needs.build.outputs.version }}
# Every version now names the commit it was built from, so the only way to meet an
# existing one is to build that same commit again - re-running the workflow, or
# re-publishing a release. Replace those artefacts rather than failing the job.
overwrite_mode: OverwriteExisting

- name: Push a package to Octopus Deploy 🐙
uses: OctopusDeploy/push-package-action@v3
with:
packages: 'package/${{ needs.build.outputs.package-basename }}'
overwrite_mode: OverwriteExisting

- name: Fetch Release Notes
id: fetch-release-notes
Expand All @@ -190,4 +207,8 @@ jobs:
with:
project: 'TeamCity Plugin'
package_version: ${{ needs.build.outputs.version }}
# This step runs on PR builds as well, so a re-run of the same commit reaches it with a
# release of that version already created. Overwriting the package is not enough on its
# own - without this the job still fails here.
ignore_existing: true
release_notes_file: ${{ steps.fetch-release-notes.outputs.release-note-file }}
Loading