Skip to content

Commit

Permalink
masesgroup#11: added scripts for CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomastrodicasa committed Jun 30, 2021
1 parent a4a1d9b commit 19d7ac2
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 2 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This is a basic workflow to help you get started with Actions

name: CI_BUILD

# Controls when the action will run. Triggers the workflow on push
# events but only for the master branch
on:
push:

# This workflow contains two jobs called "check_changes", "build_windows"
jobs:
# Verify if a build is needed
check_changes:
name: Check changed files
outputs:
run_build_windows: ${{ steps.check_files.outputs.run_build_windows }}
runs-on: ubuntu-latest
steps:
- id: get_changed_files
uses: jitterbit/get-changed-files@v1
with:
format: 'csv'
- id: check_files
run: |
mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.get_changed_files.outputs.added_modified }}')
for added_modified_file in "${added_modified_files[@]}"; do
if [[ $added_modified_file == ".github/workflows/build.yaml"* ]]; then
echo "$added_modified_file is myself."
echo "::set-output name=run_build_windows::true"
break
fi
if [[ $added_modified_file == "src/"* ]]; then
echo "$added_modified_file file is under the directory 'src/'."
echo "::set-output name=run_build_windows::true"
break
fi
done
- name: Get run_build_windows
run: echo "The selected run_build_windows is ${{ steps.check_files.outputs.run_build_windows }}"

# Now run "build_windows"
build_windows:
needs: check_changes
if: "always() && needs.check_changes.outputs.run_build_windows == 'true'"
# The type of runner that the job will run on
runs-on: windows-2019

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
# Support longpaths
- name: Support long paths
run: git config --system core.longpaths true

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: set up msvc env
uses: ilammy/[email protected]

- name: Build Common Tools
shell: cmd
run: |
cd third_party\CommonTools
msbuild -p:Configuration=Release,Platform="Any CPU" -m CommonTools.sln
- name: Extract commit SHA
run: |
echo "GITHUB_COMMIT_MESSAGE=$(echo $GITHUB_SHA)" >> $GITHUB_ENV
shell: bash

- name: Prepare version
shell: cmd
run: |
cd third_party\CommonTools\Output
VersionGenerator %GITHUB_WORKSPACE%\src\ProductInformation\Version.cs %GITHUB_WORKSPACE%\src\ProductInformation ${{ env.GITHUB_COMMIT_MESSAGE }}
env:
GITHUB_WORKSPACE: $GITHUB_WORKSPACE

- name: Build Chat net4.7.2, net5.0 and netcoreapp3.1
run: |
dotnet build --no-incremental --configuration Release --framework netcoreapp3.1 -o Outputnetcoreapp31 src\ChatCore.sln
dotnet build --no-incremental --configuration Release --framework net5.0-windows -o Outputnet50 src\ChatCore.sln
dotnet build --no-incremental --configuration Release --framework net472 -o Outputnet472 src\ChatCore.sln
- name: Prepare for packaging
run: |
Compress-Archive -Path .\Outputnetcoreapp31\* -DestinationPath .\netcoreapp31.zip
Compress-Archive -Path .\Outputnet50\* -DestinationPath .\net50.zip
Compress-Archive -Path .\Outputnet472\* -DestinationPath .\net472.zip
- uses: actions/upload-artifact@v2
with:
name: netcoreapp31
path: .\netcoreapp31.zip

- uses: actions/upload-artifact@v2
with:
name: net50
path: .\net50.zip

- uses: actions/upload-artifact@v2
with:
name: net472
path: .\net472.zip
54 changes: 54 additions & 0 deletions .github/workflows/pullrequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This is a basic workflow to help you get started with Actions

name: CI_PULLREQUEST

# Controls when the action will run. Triggers the workflow on pull request
# events but only for the master branch
on:
pull_request:
branches: [ master ]

jobs:
# This workflow contains a single job called "build_release"
build_pullrequest:
# The type of runner that the job will run on
runs-on: windows-2019
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
# Support longpaths
- name: Support long paths
run: git config --system core.longpaths true

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: set up msvc env
uses: ilammy/[email protected]

- name: Build Common Tools
shell: cmd
run: |
cd third_party\CommonTools
msbuild -p:Configuration=Release,Platform="Any CPU" -m CommonTools.sln
- name: Extract commit SHA
run: |
echo "GITHUB_COMMIT_MESSAGE=$(echo $GITHUB_SHA)" >> $GITHUB_ENV
shell: bash

- name: Prepare version
shell: cmd
run: |
cd third_party\CommonTools\Output
VersionGenerator %GITHUB_WORKSPACE%\src\ProductInformation\Version.cs %GITHUB_WORKSPACE%\src\ProductInformation ${{ env.GITHUB_COMMIT_MESSAGE }}
env:
GITHUB_WORKSPACE: $GITHUB_WORKSPACE

- name: Build Chat net4.7.2, net5.0 and netcoreapp3.1
run: |
dotnet build --no-incremental --configuration Release --framework netcoreapp3.1 -o Outputnetcoreapp31 src\ChatCore.sln
dotnet build --no-incremental --configuration Release --framework net5.0-windows -o Outputnet50 src\ChatCore.sln
dotnet build --no-incremental --configuration Release --framework net472 -o Outputnet472 src\ChatCore.sln
89 changes: 89 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# This is a basic workflow to help you get started with Actions

name: CI_RELEASE

# Controls when the action will run. Triggers the workflow on release published or release edited request
# events but only for the master branch
on:
release:
types:
- published
- edited

jobs:
# This workflow contains a single job called "build_release"
build_release:
# The type of runner that the job will run on
runs-on: windows-2019
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
# Support longpaths
- name: Support long paths
run: git config --system core.longpaths true

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: set up msvc env
uses: ilammy/[email protected]

- name: Build Common Tools
shell: cmd
run: |
cd third_party\CommonTools
msbuild -p:Configuration=Release,Platform="Any CPU" -m CommonTools.sln
- name: Extract commit SHA
run: |
echo "GITHUB_COMMIT_MESSAGE=$(echo $GITHUB_SHA)" >> $GITHUB_ENV
shell: bash

- name: Prepare version
shell: cmd
run: |
cd third_party\CommonTools\Output
VersionGenerator %GITHUB_WORKSPACE%\src\ProductInformation\Version.cs %GITHUB_WORKSPACE%\src\ProductInformation ${{ env.GITHUB_COMMIT_MESSAGE }}
env:
GITHUB_WORKSPACE: $GITHUB_WORKSPACE

- name: Build Chat net4.7.2, net5.0 and netcoreapp3.1
run: |
dotnet build --no-incremental --configuration Release --framework netcoreapp3.1 -o Outputnetcoreapp31 src\ChatCore.sln
dotnet build --no-incremental --configuration Release --framework net5.0-windows -o Outputnet50 src\ChatCore.sln
dotnet build --no-incremental --configuration Release --framework net472 -o Outputnet472 src\ChatCore.sln
- name: Prepare for packaging
run: |
Compress-Archive -Path .\Outputnetcoreapp31\* -DestinationPath .\netcoreapp31.zip
Compress-Archive -Path .\Outputnet50\* -DestinationPath .\net50.zip
Compress-Archive -Path .\Outputnet472\* -DestinationPath .\net472.zip
- name: Upload netcoreapp31 Chat binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: .\netcoreapp31.zip
asset_name: netcoreapp31
tag: ${{ github.ref }}
overwrite: true

- name: Upload net50 Chat binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: .\net50.zip
asset_name: net50
tag: ${{ github.ref }}
overwrite: true

- name: Upload net472 Chat binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: .\net472.zip
asset_name: net472
tag: ${{ github.ref }}
overwrite: true
2 changes: 1 addition & 1 deletion src/ChatLib/ChatLibCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFrameworks>net472;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1;net5.0;net5.0-windows</TargetFrameworks>
<RootNamespace>MASES.S4I.ChatLib</RootNamespace>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/CommunicationLib/CommunicationLibCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFrameworks>net472;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1;net5.0;net5.0-windows</TargetFrameworks>
<RootNamespace>MASES.S4I.CommunicationLib</RootNamespace>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down

0 comments on commit 19d7ac2

Please sign in to comment.