Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-build and upload on release #14

Merged
merged 48 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ebf4698
Update dotnet.yml
lemccomb Aug 7, 2023
36f0159
Update dotnet.yml
lemccomb Aug 8, 2023
2fe0817
Update dotnet.yml
lemccomb Aug 8, 2023
202f3bc
Update dotnet.yml
lemccomb Aug 8, 2023
c4be70c
Update dotnet.yml
lemccomb Aug 8, 2023
82b2fe5
Update dotnet.yml
lemccomb Aug 8, 2023
d978982
Update dotnet.yml
lemccomb Aug 8, 2023
3b06cfa
Update dotnet.yml
lemccomb Aug 8, 2023
e0b334b
Update dotnet.yml
lemccomb Aug 8, 2023
34a10b3
Update dotnet.yml
lemccomb Aug 8, 2023
e14e1ce
Update dotnet.yml
lemccomb Aug 8, 2023
b9a4193
Update dotnet.yml
lemccomb Aug 8, 2023
5a745aa
Update dotnet.yml
lemccomb Aug 8, 2023
e4ed845
Update dotnet.yml
lemccomb Aug 8, 2023
5b42193
Update dotnet.yml
lemccomb Aug 8, 2023
c50c171
Update dotnet.yml
lemccomb Aug 9, 2023
8315ffb
Update dotnet.yml
lemccomb Aug 9, 2023
79eb8a5
Update dotnet.yml
lemccomb Aug 9, 2023
c2d1104
Update dotnet.yml
lemccomb Aug 9, 2023
b9e21ca
Update dotnet.yml
lemccomb Aug 9, 2023
40cef46
Update dotnet.yml
lemccomb Aug 9, 2023
03a6297
Update dotnet.yml
lemccomb Aug 9, 2023
6fa30d4
Update dotnet.yml
lemccomb Aug 9, 2023
a6af8b7
Update dotnet.yml
lemccomb Aug 9, 2023
5820fe1
Update dotnet.yml
lemccomb Aug 9, 2023
a2e316e
Update dotnet.yml
lemccomb Aug 10, 2023
f375a6b
Update dotnet.yml
lemccomb Aug 14, 2023
9935cb7
Update dotnet.yml
lemccomb Aug 14, 2023
7ac0283
Update dotnet.yml
lemccomb Aug 14, 2023
eac776c
Update dotnet.yml
lemccomb Aug 14, 2023
93596c3
Update dotnet.yml
lemccomb Aug 14, 2023
9673ac5
Update dotnet.yml
lemccomb Aug 14, 2023
a568a6d
Update dotnet.yml
lemccomb Aug 14, 2023
19c412d
Update dotnet.yml
lemccomb Aug 15, 2023
3bd9582
Update dotnet.yml
lemccomb Aug 15, 2023
69aa96c
Update dotnet.yml
lemccomb Aug 15, 2023
2c6b716
Update dotnet.yml
lemccomb Aug 15, 2023
d61164c
Update dotnet.yml
lemccomb Aug 15, 2023
2555585
Update dotnet.yml
lemccomb Aug 15, 2023
88828b5
Update dotnet.yml
lemccomb Aug 15, 2023
88f020b
Update dotnet.yml
lemccomb Aug 15, 2023
de9312c
finalize build workflow
lemccomb Aug 15, 2023
feb0581
add more CodeQL queries
lemccomb Aug 15, 2023
c82adc7
codeQL tweak
lemccomb Aug 15, 2023
2e81e08
Update codeql.yml
lemccomb Aug 15, 2023
39509dc
comma no plus
lemccomb Aug 15, 2023
ab48c94
Update dotnet.yml
lemccomb Aug 15, 2023
11ad464
cleanup
lemccomb Aug 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 18 additions & 43 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
# Run CodeQL Analysis on the repository.
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/codeql-code-scanning-for-compiled-languages
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "*" ]

jobs:
analyze:
name: Analyze
# needs: build-${{matrix.os}}
runs-on: ${{ matrix.os }}
permissions:
actions: read
Expand All @@ -30,45 +18,32 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
os: [windows-latest] #, ubuntu-latest, macOS-latest]
#language: [ 'csharp' ]
os: [windows-latest, ubuntu-latest, macOS-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
languages: 'csharp'
queries: security-extended,security-and-quality
# See https://codeql.github.com/codeql-query-help/csharp/ for a list of available C# queries.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
# Use the Dotnet Build command to load dependencies and build the code.
- name: Build debug
run: dotnet build --verbosity normal CoseSignTool/CoseSignTool.sln

# Do the analysis
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
category: "/language:csharp"
100 changes: 60 additions & 40 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,86 @@
# This workflow will build a .NET project
# Build, test, publish, and upload a release of CoseSignTool
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Pull Request and Continuous Integration Build
name: Build, Test, and Publish
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "*" ]

release:
types: [created]
jobs:
build:
name: build-${{matrix.os}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macOS-latest] # macOS-latest and ubuntu-latest are broken at the moment. Add it back in when fixed.
include:
- os: windows-latest
dir_command: gci -Recurse
zip_command_debug: Compress-Archive -Path ./debug/ -DestinationPath CoseSignTool-Windows-debug.zip
zip_command_release: Compress-Archive -Path ./release/ -DestinationPath CoseSignTool-Windows-release.zip
- os: ubuntu-latest
dir_command: ls -a -R
zip_command_debug: zip -r CoseSignTool-Linux-debug.zip ./debug/
zip_command_release: zip -r CoseSignTool-Linux-release.zip ./release/
- os: macos-latest
dir_command: ls -a -R
zip_command_debug: zip -r CoseSignTool-MacOS-debug.zip ./debug/
zip_command_release: zip -r CoseSignTool-MacOS-release.zip ./release/

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x


#### This workflow runs on all platforms and handles three different types of builds:
# 1. Pull request builds: These are triggered by a pull request. They build and test the code, but do not publish or upload release artifacts.
# 2. Continuous integration builds: These are triggered by a push to the main branch. They build, test, and publish binaries for local use.
# 3. Release builds: These are triggered by a release, which is created manually. They build, test, and publish binaries, and then zip and upload them to the release.

# Use the Dotnet Test command to load dependencies, build, and test the code.
- name: Build and Test debug
# Use dotnet test to run Restore, Build, and Test, all in one sweep.
run: dotnet test --verbosity normal CoseSignTool/CoseSignTool.sln
shell: bash

- name: List working directory Windows
if: runner.os == 'Windows'
run: dir /b /a /s
shell: cmd

- name: List working directory non-Windows
if: runner.os != 'Windows' # TODO: Figure out how to set this in an environment variable so we only don't need separate steps.
run: ls -a -R
shell: bash

# The remaining steps run only when changes are pushed to Main, i.e., when a pull request completes.
# While we could run the publish steps in a parallel job, having them here forces them to wait until the unit tests pass.
# Another option to explore is to run them in a separate job that depands on ALL of the other jobs passing first.
# Eventually we might want to tweak the CodeQL job to run on what we already built above so it isn't using resources to autobuild.
- name: List working directory
run: ${{ matrix.dir_command }}

- name: Publish debug
#if: ${{ github.event_name == 'push' }}
# Publish all of the non-test projects to published/release. We have to use the solution file to get the right output paths.
run: dotnet publish --no-build --configuration Debug --output published/debug CoseSignTool/CoseSignTool.sln

- name: Publish release
#if: ${{ github.event_name == 'push' }}
# Publish CoseSignTool.exe and it's dependencies (all of the non-test projects) to published/release.
run: dotnet publish --configuration Release --output published/release CoseSignTool/CoseSignTool/CoseSignTool.csproj
- name: List published directory Windows
if: ${{ github.event_name == 'push' && runner.os == 'Windows' }}
run: dir /b /a /s
shell: cmd
# If this is a pull request build, we're done. Otherwise, publish the binaries to ./published.
# Note: We have to use the solution files to get the right output paths, due to the mix of .NET 7 and .NET Standard projects.
- name: Publish outputs
if: ${{ github.event_name != 'pull_request' }}
run: |
dotnet publish --no-build --configuration Debug --output published/debug CoseSignTool/CoseSignTool.sln
dotnet publish --configuration Release --output published/release CoseSignTool/CoseSignTool.sln

# Create zip files for release builds. Skip this step for continuous integration builds.
- name: Create zip files for release
if: ${{ github.event_name == 'release' }}
run: |
${{ matrix.zip_command_debug }}
${{ matrix.zip_command_release }}
working-directory: ./published
- name: List published directory non-Windows
if: ${{ github.event_name == 'push' && runner.os != 'Windows' }}
run: ls -a -R
shell: bash

# List the contents of the published directory to make sure all the artifacts are there.
- name: List published directory
if: ${{ github.event_name != 'pull_request' }}
run: ${{ matrix.dir_command }}
working-directory: ./published

# If this is a release build, upload the zipped artifacts.
- name: Upload release artifacts
if: ${{ github.event_name == 'release' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./published/CoseSignTool-*.zip
file_glob: true
overwrite: true





Loading