Skip to content

Commit

Permalink
The most significant changes in the code include the addition of a ne…
Browse files Browse the repository at this point in the history
…w environment variable `TAG_NAME`, the simplification of conditions for the `Build App` steps, and the update of several steps to use the `TAG_NAME` variable. Additionally, the `Upload a Build Artifact` step has been updated to only run if `CreateRelease` is false, and the paths for the `Upload a Build Artifact` and `Upload MSI to release` steps have been updated to use a backslash instead of a forward slash.

Here is a summary of the changes:

1. The descriptions for the `SelfContained` and `CreateRelease` inputs in the `build-and-release.yml` file have been updated for clarity. This change improves the understanding of these inputs.
2. The `run-name` has been updated to include a 'v' before the version number. This change makes the version number more recognizable.
3. A new environment variable `TAG_NAME` has been added, which includes a 'v' before the `CreateRelease` input. This change standardizes the tag naming convention.
4. The validation message for the version format has been updated to include a period at the end. This change improves the readability of the message.
5. The conditions for the `Build App` and `Build App (Self-contained)` steps have been simplified. This change makes the code cleaner and easier to understand.
6. The condition for the `Upload a Build Artifact` step has been updated to only run if `CreateRelease` is false. This change prevents unnecessary execution of the step.
7. The `Create tag`, `Create release draft`, and `Upload MSI to release` steps have been updated to use the `TAG_NAME` environment variable instead of the `Version` input. This change ensures consistency in the use of the new `TAG_NAME` variable.
8. The paths for the `Upload a Build Artifact` and `Upload MSI to release` steps have been updated to use a backslash instead of a forward slash. This change corrects the path format.
9. The `Create release draft` and `Upload MSI to release` steps have been updated to use the `TAG_NAME` environment variable in the title and upload command respectively. This change ensures that the correct tag name is used in these steps.
  • Loading branch information
amgdy committed Apr 23, 2024
1 parent 73fad24 commit 96b591f
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ on:
required: true
default: "1.0.1"
SelfContained:
description: "Self-contained build"
description: "Create Self-contained Build"
required: true
type: boolean
default: false
CreateRelease:
description: "Create Release"
description: "Create GitHub Release"
required: true
type: boolean
default: false

name: 🏗️ Build & Release
run-name: 🏗️ Build & Release ${{ github.event.inputs.Version }}

run-name: 🏗️ Build & Release v${{ github.event.inputs.Version }}

permissions:
contents: write


env:
VERSION: ${{ github.event.inputs.Version }}
SELF_CONTAINED: ${{ github.event.inputs.SelfContained }}
TAG_NAME: v${{ github.event.inputs.CreateRelease }}

jobs:
build:
Expand All @@ -42,10 +41,10 @@ jobs:
steps:
- name: 🦺 Validate version format
run: |
if ('${{ github.event.inputs.Version }}' -notmatch '^\d+\.\d+\.\d+$') {
Write-Output "Version format is invalid."
exit 1
}
if ('${{ github.event.inputs.Version }}' -notmatch '^\d+\.\d+\.\d+$') {
Write-Output "Version format is invalid."
exit 1
}
- name: 📥 Checkout code
uses: actions/checkout@v4.1.2
Expand All @@ -70,11 +69,11 @@ jobs:
run: dotnet restore src

- name: 🏗️ Build App
if: ${{ github.event.inputs.SelfContained == 'false' }}
if: github.event.inputs.SelfContained == false
run: dotnet publish ${{env.APP_PROJECT_PATH}} -c=Release -o=${{env.APP_PROJECT_OUTPUT}} --p:FileVersion=${{env.VERSION}} --p:AssemblyVersion=${{env.VERSION}} --p:Version=${{env.VERSION}} -p:SourceRevisionId=${{ github.sha }}

- name: 🏗️ Build App (Self-contained)
if: ${{ github.event.inputs.SelfContained == 'true' }}
if: github.event.inputs.SelfContained
run: dotnet publish ${{env.APP_PROJECT_PATH}} -c=Release -o=${{env.APP_PROJECT_OUTPUT}} --p:FileVersion=${{env.VERSION}} --p:AssemblyVersion=${{env.VERSION}} --p:Version=${{env.VERSION}} -r=win-x64 --self-contained=true -p:SourceRevisionId=${{ github.sha }}

- name: 🔧 Setup WiX v5
Expand All @@ -84,27 +83,28 @@ jobs:
run: dotnet build ${{env.MSI_PROJECT_PATH}} -c=Release -o=${{env.MSI_PROJECT_OUTPUT}} -p:Version=${{env.VERSION}} -p:AppDir=${{env.APP_PROJECT_OUTPUT}} -p:OutputName=${{env.MSI_FILE_NAME}} -p:SourceRevisionId=${{ github.sha }}

- name: 📤 Upload a Build Artifact
if: github.event.inputs.CreateRelease == false
uses: actions/upload-artifact@v4.3.1
with:
name: ${{env.MSI_FILE_NAME}}
path: ${{env.MSI_PROJECT_OUTPUT}}/${{env.MSI_FILE_NAME}}.msi
path: ${{env.MSI_PROJECT_OUTPUT}}\${{env.MSI_FILE_NAME}}.msi

- name: 🏷️ Create tag ${{ github.event.inputs.Version }}
if: github.event.inputs.CreateRelease
run: |
git tag ${{ github.event.inputs.Version }}
git push origin ${{ github.event.inputs.Version }}
git tag ${{ github.event.inputs.Version }}
git push origin ${{ github.event.inputs.Version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 📝 Create release draft ${{ github.event.inputs.Version }}
- name: 📝 Create release draft ${{ env.TAG_NAME }}
if: github.event.inputs.CreateRelease
run: gh release create ${{ github.event.inputs.Version }} --target ${{ github.ref }} --draft --title "${{ github.event.inputs.version }}" --generate-notes --prerelease --draft
run: gh release create ${{ env.TAG_NAME }} --target ${{ github.ref }} --draft --title "${{ env.TAG_NAME }}" --generate-notes --prerelease --draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 📤 Upload MSI to release ${{ github.event.inputs.Version }}
- name: 📤 Upload MSI to release ${{ env.TAG_NAME }}
if: github.event.inputs.CreateRelease
run: gh release upload ${{ github.event.inputs.Version }} ${{env.MSI_PROJECT_OUTPUT}}/${{env.MSI_FILE_NAME}}.msi
run: gh release upload ${{ env.TAG_NAME }} ${{env.MSI_PROJECT_OUTPUT}}\${{env.MSI_FILE_NAME}}.msi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 96b591f

Please sign in to comment.