This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
Update settings.py #27
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: msptool | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
env: | |
Solution_Directory: msptool/msptool | |
Solution_Name: msptool/msptool/msptool.sln | |
Version_File: msptool/version.txt | |
Program_File: msptool/msptool/Program.cs | |
Version_Pattern: '([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)' | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up MSBuild | |
uses: microsoft/setup-msbuild@v2 | |
- name: Restore dependencies | |
run: msbuild ${{ env.Solution_Name }} /t:Restore /p:Configuration=${{ matrix.configuration }} | |
- name: Build application | |
run: msbuild ${{ env.Solution_Name }} /p:Configuration=${{ matrix.configuration }} | |
- name: Check for security updates | |
if: github.event_name == 'pull_request' | |
uses: actions/dependency-review-action@v2 | |
with: | |
fail-on-severity: low | |
fail-on-scopes: runtime | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update version number | |
id: update_version | |
shell: pwsh | |
run: | | |
# Read the current version | |
$version = Get-Content $env:Version_File | |
$version_parts = $version -split '\.' | |
# Extract version components | |
$major = $version_parts[0] | |
$minor = $version_parts[1] | |
$patch = $version_parts[2] | |
$build = [int]$version_parts[3] + 1 | |
$new_version = "$major.$minor.$patch.$build" | |
Set-Content -Path $env:Version_File -Value $new_version | |
(Get-Content $env:Program_File) -replace 'private static readonly string vloc1 = ".*";', "private static readonly string vloc1 = `"$new_version`";" | Set-Content -Path $env:Program_File | |
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV | |
- name: Commit version updates | |
run: | | |
git config --local user.name "github-actions" | |
git config --local user.email "actions@github.com" | |
git add ${{ env.Version_File }} ${{ env.Program_File }} | |
git commit -m "Update version to ${{ env.NEW_VERSION }}" | |
# Fetch latest changes and merge them | |
git pull --rebase origin main | |
# Push the changes | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Git tag | |
shell: pwsh | |
run: | | |
# Print current tags for debugging | |
git tag -l | |
# Print the new version for debugging | |
Write-Output "Creating tag v${{ env.NEW_VERSION }}" | |
# Create and push new tag if it doesn't already exist | |
if (git tag -l "v${{ env.NEW_VERSION }}") { | |
Write-Output "Tag v${{ env.NEW_VERSION }} already exists." | |
} else { | |
git tag "v${{ env.NEW_VERSION }}" | |
git push origin "v${{ env.NEW_VERSION }}" | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ env.Solution_Directory }}/**/bin/${{ matrix.configuration }}/** | |
name: "MspTool v${{ env.NEW_VERSION }}" | |
body: "This release includes the following updates:\n\n- Incremented build version.\n- Updated Program.cs with the new version string.\n- Other minor improvements and fixes." # Description of the release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Build Artifacts | |
path: ${{ env.Solution_Directory }}/**/bin/${{ matrix.configuration }}/** |