Token assets #953
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: .NET | |
on: | |
push: | |
branches: "**" | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get Short SHA | |
id: short-sha | |
run: echo "short_sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
- name: Set Lowercase Variables | |
id: vars | |
shell: bash | |
run: | | |
echo "IMAGE_NAME=$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
echo "BRANCH_NAME=$(echo ${GITHUB_REF_NAME} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Modify asset versions | |
uses: mingjun97/file-regex-replace@v1 | |
with: | |
regex: '\$\(SHORTHASH\)' | |
replacement: '${{ steps.short-sha.outputs.short_sha }}' | |
flags: "g" | |
include: '.*' | |
exclude: '.^' | |
encoding: 'utf8' | |
path: '.' | |
- name: Delete .js files if corresponding .ts files exist | |
run: | | |
#!/bin/bash | |
SEARCH_DIR="./" | |
find "$SEARCH_DIR" -name "*.ts" | while read tsfile; do | |
jsfile="${tsfile%.ts}.js" | |
if [ -f "$jsfile" ]; then | |
echo "Deleting $jsfile because $tsfile exists" | |
rm "$jsfile" | |
fi | |
done | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 9.0.100-rc.1.24452.12 | |
include-prerelease: true | |
- name: Restore workload | |
run: dotnet workload restore | |
- name: Clean | |
run: dotnet clean | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Clean | |
run: dotnet clean | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
continue-on-error: true | |
- name: Publish Test Results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Test Results | |
path: "**/test_results.trx" | |
- name: Publish Shared Nuget Package | |
uses: alirezanet/publish-nuget@v3.1.0 | |
with: | |
PROJECT_FILE_PATH: Valour/Shared/Valour.Shared.csproj | |
VERSION_FILE_PATH: Valour/Shared/Valour.Shared.csproj | |
NUGET_KEY: ${{ secrets.NUGET_API_KEY }} | |
- name: Publish API Nuget Package | |
uses: alirezanet/publish-nuget@v3.1.0 | |
with: | |
PROJECT_FILE_PATH: Valour/Sdk/Valour.Sdk.csproj | |
VERSION_FILE_PATH: Valour/Sdk/Valour.Sdk.csproj | |
NUGET_KEY: ${{ secrets.NUGET_API_KEY }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ steps.short-sha.outputs.short_sha }} | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-latest | |
labels: | | |
org.opencontainers.image.source=${{ github.repository }} | |
org.opencontainers.image.revision=${{ github.sha }} |