Build, Test, Package and Push #934
This file contains 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, Test, Package and Push | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on pull request events and merges/pushes to main | |
push: | |
branches: | |
- main | |
- release/* | |
tags-ignore: | |
- '**' | |
pull_request: | |
types: [opened, synchronize, reopened] | |
schedule: | |
# Daily 5am australian/brisbane time | |
- cron: '0 19 * * *' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Pass branch and patch number to Nuke OctoVersion | |
# (for pull_request events we override the /refs/pull/xx/merge branch to the PR's head branch) | |
env: | |
OCTOVERSION_CurrentBranch: ${{ github.head_ref || github.ref }} | |
OCTOVERSION_Patch: ${{ github.run_number }} | |
AssentNonInteractive: true | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # all | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
# Adjustment is done prior to Nuke build as OCTOVERSION information is included in the result package. | |
- name: Append OCTOVERSION_CurrentBranch with -nightly (for scheduled) | |
if: github.event_name == 'schedule' | |
run: echo "OCTOVERSION_CurrentBranch=${{ env.OCTOVERSION_CurrentBranch }}-nightly" >> $GITHUB_ENV | |
- name: Nuke Build 🏗 | |
id: build | |
shell: bash | |
run: ./build.sh | |
- name: Tag release (when not pre-release) 🏷️ | |
id: github-tag | |
if: ${{ github.event_name != 'schedule' && !contains( steps.build.outputs.octoversion_fullsemver, '-' ) }} | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/${{ steps.build.outputs.octoversion_fullsemver }}", | |
sha: context.sha | |
}) | |
- name: Push to Octopus 🐙 | |
uses: OctopusDeploy/push-package-action@v3 | |
with: | |
server: ${{ secrets.DEPLOY_URL }} | |
space: Integrations | |
api_key: ${{ secrets.DEPLOY_API_KEY }} | |
packages: | | |
./artifacts/Octopus.Versioning.${{ steps.build.outputs.octoversion_fullsemver }}.nupkg | |
- name: Create Release in Octopus 🐙 | |
uses: OctopusDeploy/create-release-action@v3 | |
with: | |
server: ${{ secrets.DEPLOY_URL }} | |
space: Integrations | |
api_key: ${{ secrets.DEPLOY_API_KEY }} | |
project: "Versioning" | |
packages: | | |
Octopus.Versioning:${{ steps.build.outputs.octoversion_fullsemver }} |