Skip to content

Commit

Permalink
init source code
Browse files Browse the repository at this point in the history
Signed-off-by: Sang Au <[email protected]>
  • Loading branch information
auvansang committed Oct 20, 2024
1 parent 625191b commit 5939aca
Show file tree
Hide file tree
Showing 22 changed files with 2,272 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build Validation
on:
push:
branches:
- feature/*
- bugfix/*
paths:
- '**.cs'
- '**.csproj'

pull_request:
branches:
- main
paths:
- '**.cs'
- '**.csproj'

workflow_dispatch:

jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-22.04
runtime: linux-x64
- os: ubuntu-22.04
runtime: linux-arm64
- os: macos-14
runtime: osx-x64
- os: macos-14
runtime: osx-arm64
- os: windows-2022
runtime: win-x64
- os: windows-2022
runtime: win-arm64
runs-on: ${{ matrix.os }}
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
cache: true
config-file: ./nuget.config
cache-dependency-path: '**/packages.lock.json'

- name: Install Dependencies
shell: bash
run: dotnet restore src --locked-mode

- name: Build
shell: bash
run: dotnet build src/CertGen --configuration Release --runtime ${{ matrix.runtime }} --no-restore

# See: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/cross-compile#linux
- name: Install Packages for linux-arm64
if: ${{ matrix.runtime == 'linux-arm64' }}
shell: bash
run: |
sudo dpkg --add-architecture arm64
sudo bash -c 'cat > /etc/apt/sources.list.d/arm64.list <<EOF
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
EOF'
sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
sudo sed -i -e 's/deb mirror/deb [arch=amd64] mirror/g' /etc/apt/sources.list
sudo apt update
sudo apt install -y clang llvm binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu zlib1g-dev:arm64
- name: Publish Artifact
id: publish
shell: bash
run: |
dotnet publish src/CertGen --configuration Release --runtime ${{ matrix.runtime }} --no-restore --no-build
62 changes: 62 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CodeQL Analysis
on:
push:
branches:
- main
paths:
- '**.cs'
- '**.csproj'

pull_request:
branches:
- main
paths:
- '**.cs'
- '**.csproj'

schedule:
- cron: '0 0 * * *'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on:
- ubuntu-22.04
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
language:
- csharp

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
source-root: src

- name: Build
uses: github/codeql-action/autobuild@v3
with:
working-directory: src

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: '/language:${{matrix.language}}'
141 changes: 141 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Pre-Release
on:
workflow_dispatch:

jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-22.04
runtime: linux-x64
- os: ubuntu-22.04
runtime: linux-arm64
- os: macos-14
runtime: osx-x64
- os: macos-14
runtime: osx-arm64
- os: windows-2022
runtime: win-x64
- os: windows-2022
runtime: win-arm64
runs-on: ${{ matrix.os }}
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
ARTIFACTS_DIR: ''
outputs:
SemVer2: ${{ steps.versioning.outputs.SemVer2 }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
cache: true
config-file: nuget.config
cache-dependency-path: '**/packages.lock.json'

- name: Setup Nerdbank.GitVersioning
uses: dotnet/nbgv@master
id: versioning
with:
path: src/CertGen

- name: Install Dependencies
shell: bash
run: dotnet restore src --locked-mode

- name: Build
shell: bash
run: |
dotnet build src/CertGen \
--configuration Release \
--runtime ${{ matrix.runtime }} \
--no-restore \
-p:PublicRelease=true \
-p:Version=${{ steps.versioning.outputs.CloudBuildNumber }} \
-p:AssemblyVersion=${{ steps.versioning.outputs.AssemblyVersion }} \
-p:FileVersion=${{ steps.versioning.outputs.AssemblyFileVersion }} \
-p:AssemblyInformationalVersion=${{ steps.versioning.outputs.AssemblyInformationalVersion }}
# See: https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/cross-compile#linux
- name: Install Packages for linux-arm64
if: ${{ matrix.runtime == 'linux-arm64' }}
shell: bash
run: |
sudo dpkg --add-architecture arm64
sudo bash -c 'cat > /etc/apt/sources.list.d/arm64.list <<EOF
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
EOF'
sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
sudo sed -i -e 's/deb mirror/deb [arch=amd64] mirror/g' /etc/apt/sources.list
sudo apt update
sudo apt install -y clang llvm binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu zlib1g-dev:arm64
- name: Publish Artifact
id: publish
shell: bash
run: |
ARTIFACTS_DIR=cert-gent_v${{ steps.versioning.outputs.SemVer2 }}_${{ matrix.runtime }}
echo "ARTIFACTS_DIR=$ARTIFACTS_DIR" >> $GITHUB_ENV
dotnet publish src/CertGen --configuration Release --runtime ${{ matrix.runtime }} --no-restore --no-build --output $ARTIFACTS_DIR
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACTS_DIR }}
path: ${{ env.ARTIFACTS_DIR }}
if-no-files-found: error
include-hidden-files: true
retention-days: 90

release:
runs-on: ubuntu-22.04
needs:
- build
permissions:
contents: write
steps:
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
gh release create v${{ needs.build.outputs.SemVer2 }} \
--title v${{ needs.build.outputs.SemVer2 }} \
--target ${{ github.sha }} \
--latest=false \
--prerelease \
--repo ${{ github.repository }} \
--generate-notes
- name: Download Release Artifact
uses: actions/download-artifact@v4
with:
path: downloaded
pattern: cert-gent_v${{ needs.build.outputs.SemVer2 }}_*

- name: Zip Release Artifact
shell: bash
run: |
mkdir artifacts
cd downloaded
for artifact in */; do
artifact_dir=$(basename "$artifact")
tar -czvf "../artifacts/${artifact%/}.tar.gz" -C "${artifact_dir}" .
done
- name: Publish Release Artifact to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
gh release upload v${{ needs.build.outputs.SemVer2 }} artifacts/* \
--clobber \
--repo ${{ github.repository }}
Loading

0 comments on commit 5939aca

Please sign in to comment.