-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INFRASTRUCTURE: Updated build script
- Loading branch information
Showing
2 changed files
with
77 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,33 +43,52 @@ jobs: | |
- name: Test | ||
run: dotnet test --no-build --verbosity normal | ||
add_tag: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
if: > | ||
github.event.pull_request.merged && | ||
github.event.pull_request.base.ref == 'master' && | ||
startsWith(github.event.pull_request.title, 'RELEASES:') && | ||
contains(github.event.pull_request.labels.*.name, 'RELEASES') | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Extract Version Number | ||
id: extract_version | ||
run: |- | ||
echo "::set-output name=version_number::$(grep -oP '(?<=<Version>)[^<]+' ADotNet/ADotNet.csproj)" | ||
echo "version_number=$(grep -oP '(?<=<Version>)[^<]+' ADotNet/ADotNet.csproj)" >> $GITHUB_OUTPUT | ||
echo "package_release_notes=$(grep -oP '(?<=<PackageReleaseNotes>)[^<]+' ADotNet/ADotNet.csproj)" >> $GITHUB_OUTPUT | ||
- name: Print Version Number | ||
run: |- | ||
echo "Version number is ${{ steps.extract_version.outputs.version_number }}" | ||
echo "Version number - v${{ steps.extract_version.outputs.version_number }}" | ||
echo "Release Notes - ${{ steps.extract_version.outputs.package_release_notes }}" | ||
- name: Configure Git | ||
run: |- | ||
git config user.name "Add Git Release Tag Action" | ||
git config user.email "github.action@noreply.github.com" | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
- name: Authenticate with GitHub | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT_FOR_TAGGING }} | ||
- name: Add Git Tag - Release | ||
- name: Add Release Tag | ||
run: |- | ||
git tag -a "release-${{ steps.extract_version.outputs.version_number }}" -m "Release ${{ steps.extract_version.outputs.version_number }}" | ||
git tag -a "v${{ steps.extract_version.outputs.version_number }}" -m "Release - v${{ steps.extract_version.outputs.version_number }}" | ||
git push origin --tags | ||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGGING }} | ||
with: | ||
tag_name: v${{ steps.extract_version.outputs.version_number }} | ||
release_name: Release - v${{ steps.extract_version.outputs.version_number }} | ||
body: >- | ||
### Release - v${{ steps.extract_version.outputs.version_number }} | ||
#### Release Notes | ||
${{ steps.extract_version.outputs.package_release_notes }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
// --------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using ADotNet.Clients; | ||
using ADotNet.Models.Pipelines.GithubPipelines.DotNets; | ||
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks; | ||
|
@@ -83,16 +84,16 @@ static void Main(string[] args) | |
}, | ||
AddTag = new TagJob | ||
{ | ||
RunsOn = BuildMachines.UbuntuLatest, | ||
|
||
Needs = new string[] { "build" }, | ||
|
||
If = | ||
"github.event.pull_request.merged &&\r" | ||
+ "github.event.pull_request.base.ref == 'master' &&\r" | ||
+ "startsWith(github.event.pull_request.title, 'RELEASES:') &&\r" | ||
+ "contains(github.event.pull_request.labels.*.name, 'RELEASES')\r", | ||
|
||
RunsOn = BuildMachines.UbuntuLatest, | ||
|
||
Needs = new string[] { "build" }, | ||
|
||
Steps = new List<GithubTask> | ||
{ | ||
new CheckoutTaskV3 | ||
|
@@ -104,22 +105,26 @@ static void Main(string[] args) | |
{ | ||
Name = "Extract Version Number", | ||
Id = "extract_version", | ||
Run = "echo \"::set-output name=version_number::$(grep -oP '(?<=<Version>)[^<]+' ADotNet/ADotNet.csproj)\"" | ||
Run = | ||
"echo \"version_number=$(grep -oP '(?<=<Version>)[^<]+' ADotNet/ADotNet.csproj)\" >> $GITHUB_OUTPUT\r" | ||
+ "echo \"package_release_notes=$(grep -oP '(?<=<PackageReleaseNotes>)[^<]+' ADotNet/ADotNet.csproj)\" >> $GITHUB_OUTPUT" | ||
}, | ||
|
||
new ShellScriptTask | ||
{ | ||
Name = "Print Version Number", | ||
Run = "echo \"Version number is ${{ steps.extract_version.outputs.version_number }}\"" | ||
Run = | ||
"echo \"Version number - v${{ steps.extract_version.outputs.version_number }}\"\r" | ||
+ "echo \"Release Notes - ${{ steps.extract_version.outputs.package_release_notes }}\"" | ||
}, | ||
|
||
new ShellScriptTask | ||
{ | ||
Name = "Configure Git", | ||
Run = | ||
"git config user.name \"Add Git Release Tag Action\"" | ||
"git config user.name \"GitHub Action\"" | ||
+ "\r" | ||
+ "git config user.email \"github.action@noreply.github.com\"" | ||
+ "git config user.email \"[email protected]\"" | ||
}, | ||
|
||
new CheckoutTaskV3 | ||
|
@@ -133,18 +138,49 @@ static void Main(string[] args) | |
|
||
new ShellScriptTask | ||
{ | ||
Name = "Add Git Tag - Release", | ||
Name = "Add Release Tag", | ||
Run = | ||
"git tag -a \"release-${{ steps.extract_version.outputs.version_number }}\" -m \"Release ${{ steps.extract_version.outputs.version_number }}\"" | ||
+ "\r" | ||
"git tag -a \"v${{ steps.extract_version.outputs.version_number }}\" -m \"Release - v${{ steps.extract_version.outputs.version_number }}\"\r" | ||
+ "git push origin --tags" | ||
}, | ||
|
||
new ReleaseTaskV1 | ||
{ | ||
Name = "Create Release", | ||
Uses = "actions/create-release@v1", | ||
|
||
EnvironmentVariables = new Dictionary<string, string> | ||
{ | ||
{ "GITHUB_TOKEN", "${{ secrets.PAT_FOR_TAGGING }}" } | ||
}, | ||
|
||
With = new Dictionary<string, string> | ||
{ | ||
{ "tag_name", "v${{ steps.extract_version.outputs.version_number }}" }, | ||
{ "release_name", "Release - v${{ steps.extract_version.outputs.version_number }}" }, | ||
|
||
{ "body", | ||
"### Release - v${{ steps.extract_version.outputs.version_number }}\r" | ||
+ "\r" | ||
+ "#### Release Notes\r" | ||
+ "${{ steps.extract_version.outputs.package_release_notes }}" | ||
}, | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
aDotNetClient.SerializeAndWriteToFile(githubPipeline, "../../../../.github/workflows/dotnet.yml"); | ||
string buildScriptPath = "../../../../.github/workflows/dotnet.yml"; | ||
string directoryPath = Path.GetDirectoryName(buildScriptPath); | ||
|
||
if (!Directory.Exists(directoryPath)) | ||
{ | ||
Directory.CreateDirectory(directoryPath); | ||
} | ||
|
||
aDotNetClient.SerializeAndWriteToFile(githubPipeline, path: buildScriptPath); | ||
} | ||
} | ||
} | ||
} |