Skip to content

fix: updated build script #7

fix: updated build script

fix: updated build script #7

Workflow file for this run

name: Essentials Plugin Build Get Version
on:
push:
branches:
- feature-2.0.0/*
- hotfix-2.0.0/*
- release-2.0.0/*
- development-2.0.0
jobs:
Build_Project_4-Series:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Get branch name
id: get_branch
run: |
branch=${GITHUB_REF#refs/heads/}
echo "branch=$branch" >> $GITHUB_OUTPUT
echo "prerelease=${branch//\//-}" >> $GITHUB_OUTPUT
env:
GITHUB_REF: ${{ github.ref }}
- name: Set Version Number and Phase
id: get_version
run: |
# Set initial version
latestVersion="2.0.0"
newVersion="$latestVersion"
phase=""
newVersionString=""
# Output current GitHub Ref
echo "Current GitHub Ref: $GITHUB_REF"
# Determine the phase and version string based on the branch
case $GITHUB_REF in
refs/pull/*)
phase="beta"
newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}"
;;
refs/heads/hotfix-2.0.0/*)
phase="hotfix"
newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}"
;;
refs/heads/release-2.0.0/*)
splitRef=(${GITHUB_REF//\// })
version="${splitRef[-1]//v/}"
phase="rc"
newVersionString="${version}-${phase}-${GITHUB_RUN_NUMBER}"
;;
refs/heads/feature-2.0.0/*)
phase="alpha"
newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}"
;;
development-2.0.0)
phase="beta"
newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}"
;;
esac
# Output the final determined version and build phase
echo "Version to be used: $newVersionString"
echo "Build Phase: $phase"
# Write the version to the GitHub environment file
echo "version=$newVersionString" >> $GITHUB_ENV
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.x"
- name: Restore .NET dependencies
run: dotnet restore
- name: Build .NET project
run: dotnet build --configuration Release -p:Version=${{ steps.get_version.outputs.version }}
- name: Pack .NET project
run: dotnet pack --configuration Release -p:Version=${{ steps.get_version.outputs.version }} --output ./output
- run: ls -la
- name: Create Release
id: create_release
if: steps.get_version.outputs.newVersion == 'true'
uses: ncipollo/release-action@v1
with:
prerelease: ${{ steps.get_branch.outcome.branch != 'main' }}
artifacts: "output/**/*.*(cpz|cplz)"
tag: ${{ steps.get_version.outputs.tag }}
commit: ${{ github.sha }}
bodyFile: ./CHANGELOG.md
- name: Print results
if: steps.get_version.outputs.newVersion == 'true'
run: |
echo "# Summary" >> $GITHUB_STEP_SUMMARY
echo "Version: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "Tag: ${{ steps.get_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "New Version: ${{ steps.get_version.outputs.newVersion }}" >> $GITHUB_STEP_SUMMARY
echo "Channel: ${{ steps.get_version.outputs.channel }}" >> $GITHUB_STEP_SUMMARY
echo "Type: ${{ steps.get_version.outputs.type }}" >> $GITHUB_STEP_SUMMARY