Finxing windows build #12
This file contains hidden or 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: Build and Publish .NET Core App | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: {} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Install CycloneDX | |
run: dotnet tool install --global CycloneDX | |
shell: bash | |
- name: Generate SBOM | |
run: dotnet-CycloneDX WindowsServiceDotNETCore.csproj --output . --output-format json | |
shell: bash | |
- name: Set Version | |
run: echo "PACKAGE_VERSION=$(date +'%Y%m%d').${{ github.run_number }}.${{ github.run_attempt }}" >> $GITHUB_ENV | |
shell: bash | |
- name: Install maven-repository-aws-s3 dependencies | |
run: | | |
HOME=$(dirname $(readlink -f $(which mvn))) | |
for dep in "com.github.ehsaniara:maven-repository-aws-s3:1.2.11:jar" "org.apache.httpcomponents:httpcore:4.4.16:jar" "com.amazonaws:aws-java-sdk-s3:1.12.405:jar" "com.amazonaws:aws-java-sdk-core:1.12.405:jar" "com.fasterxml.jackson.core:jackson-core:2.14.2:jar" "com.fasterxml.jackson.core:jackson-databind:2.14.2:jar" "com.fasterxml.jackson.core:jackson-annotations:2.14.2:jar" "joda-time:joda-time:2.12.2:jar" "org.apache.httpcomponents:httpclient:4.5.14:jar" "commons-io:commons-io:2.12.0" | |
do | |
mvn dependency:copy \ | |
--batch-mode \ | |
-DrepoUrl=https://repo.maven.apache.org/maven2 \ | |
-Dartifact=${dep} \ | |
-DoutputDirectory=${HOME}/../lib | |
done | |
shell: bash | |
- name: Configure maven-repository-aws-s3 | |
run: | | |
mkdir -p ~/.m2 | |
cat <<EOT > ~/.m2/settings.xml | |
<settings> | |
<servers> | |
<server> | |
<id>octopus-sales-public-snapshot</id> | |
<username>${{ secrets.AWS_ACCESS_KEY_ID }}</username> | |
<password>${{ secrets.AWS_SECRET_ACCESS_KEY }}</password> | |
<configuration> | |
<region>ap-southeast-2</region> | |
<publicRepository>true</publicRepository> | |
</configuration> | |
</server> | |
<server> | |
<id>octopus-sales-public-release</id> | |
<username>${{ secrets.AWS_ACCESS_KEY_ID }}</username> | |
<password>${{ secrets.AWS_SECRET_ACCESS_KEY }}</password> | |
<configuration> | |
<region>ap-southeast-2</region> | |
<publicRepository>true</publicRepository> | |
</configuration> | |
</server> | |
</servers> | |
</settings> | |
EOT | |
shell: bash | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --configuration Release --no-restore | |
- name: Publish | |
run: dotnet publish --configuration Release --output ./publish | |
- name: Build and push static web package | |
run: | | |
pushd publish | |
zip -r ../windowsservice.${{ env.PACKAGE_VERSION }}.zip . | |
popd | |
mvn deploy:deploy-file \ | |
--batch-mode \ | |
"-DgroupId=com.octopus" \ | |
"-DartifactId=windowsservice" \ | |
"-Dversion=${{ env.PACKAGE_VERSION }}" \ | |
"-Dpackaging=zip" \ | |
"-Dfile=windowsservice.${{ env.PACKAGE_VERSION }}.zip" \ | |
"-DrepositoryId=octopus-sales-public-snapshot" \ | |
"-Durl=s3://octopus-sales-public-maven-repo/snapshot" | |
shell: bash |