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

Csharp builds #70

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 51 additions & 0 deletions .github/actions/build-migration/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Maven Build
description: Run a Maven Build

inputs:
build-command:
description: The Maven command to build the project. The default is `package`.
required: false
# type: string - `type` field is not supported (yet). See comment below.
default: install
release-name:
description: The Maven artifact name and version.
required: true
build-flags:
description: The Maven build flags
required: false
default: '-Dmaven.repo.local=$GITHUB_WORKSPACE/.m2' # why the local artifactory is required
#deploy-flags: #compose from build-flags and maven-settings
# description: The Maven deploy flags
# required: false
# default: '-s $GITHUB_WORKSPACE/settings.xml -Dmaven.repo.local=$GITHUB_WORKSPACE/.m2' # not required since actions/setup-java allows the definition of the settings file path and build-flags already define the ref to the local artifactory
build-profiles:
description: The maven build profiles
required: false
default: 'daml,scala,typescript,golang,csharp8,csharp9,kotlin,python,full,gpg,excel' # TBD whether this is useful for the parallel build tasks
maven-settings:
description: The Maven settings file
required: false
default: $GITHUB_WORKSPACE

runs:
using: "composite"
steps:
- name: Set up JDK 11 for x64
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
architecture: x64
cache: maven
server-id: ossrh
server-username: CI_DEPLOY_USERNAME
server-password: CI_DEPLOY_PASSWORD
settings-path: ${{inputs.maven-settings}}
gpg-private-key: GPG_PRIVATE_KEY
gpg-passphrase: GPG_PASSPHRASE
- name: Set artifact version with Maven
shell: bash
run: mvn ${{inputs.build-flags}} versions:set -DnewVersion=${{inputs.release-name}} versions:update-child-modules -DallowSnapshots=true
- name: Build and deploy artifact with Maven
shell: bash
run: mvn ${{inputs.build-flags}} clean ${{inputs.build-command}} -P ${{inputs.build-profiles}}
149 changes: 149 additions & 0 deletions .github/workflows/build-migration-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Java CI with Maven

on:
push: #triggers on tag push event
tags:
- '**'
pull_request: #triggers on PR merge event into develop branch
types:
- closed

jobs:
setup: # defines the variables used across all job's steps and output variables to be used across jobs.
runs-on: ubuntu-latest
env: # environment variables used across the setup job
MVN_BUILD_FLAGS: "-Dmaven.repo.local=$GITHUB_WORKSPACE/.m2"
MVN_DEPLOY_FLAGS: "-s $GITHUB_WORKSPACE/settings.xml"
GEN_DEPLOY_POM_SCRIPT: "$GITHUB_WORKSPACE/rosetta-source/src/main/resources/build-resources/create-deploy-pom.sh"
GEN_DEPLOY_POM_PY: "$GITHUB_WORKSPACE/rosetta-source/src/main/resources/build-resources/create-deploy-pom.py"
outputs:
MVN_BUILD_FLAGS: ${{env.MVN_BUILD_FLAGS}}
MVN_DEPLOY_FLAGS: ${{env.MVN_DEPLOY_FLAGS}}
RELEASE_NAME: ${{steps.release_props.outputs.RELEASE_NAME}}
RELEASE_MAVEN_BUILD_PROFILES: ${{steps.release_props.outputs.MAVEN_BUILD_PROFILES}}
RELEASE_MVN_DEPLOY_FILE_FLAGS: ${{steps.release_props.outputs.MVN_DEPLOY_FILE_FLAGS}}
SNAPSHOT_NAME: ${{steps.snapshot_props.outputs.RELEASE_NAME}}
SNAPSHOT_MAVEN_BUILD_PROFILES: ${{steps.snapshot_props.outputs.MAVEN_BUILD_PROFILES}}
SNAPSHOT_MVN_DEPLOY_FILE_FLAGS: ${{steps.snapshot_props.outputs.MVN_DEPLOY_FILE_FLAGS}}

steps:
- name: main_clone
uses: actions/checkout@v4

- name: ReleaseProperties
id: release_props
if: startsWith(github.ref, 'refs/tags')
shell: bash
run: |
echo "RELEASE_NAME=${{env.RELEASE_NAME}}" >> "$GITHUB_OUTPUT"
echo "RELEASE_MAVEN_BUILD_PROFILES=${{env.MAVEN_BUILD_PROFILES}}" >> "$GITHUB_OUTPUT"
echo "RELEASE_MVN_DEPLOY_FILE_FLAGS=${{env.MVN_DEPLOY_FILE_FLAGS}}" >> "$GITHUB_OUTPUT"
env:
RELEASE_NAME: "${{github.event.release.tag_name}}"
MAVEN_BUILD_PROFILES: "daml,scala,typescript,golang,csharp8,csharp9,kotlin,python,full,gpg,excel"
MVN_DEPLOY_FILE_FLAGS: "${{env.MVN_BUILD_FLAGS}} ${{env.MVN_DEPLOY_FLAGS}} -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2 -DrepositoryId=ossrh-distro"

- name: SnapshotProperties
id: snapshot_props
if: github.ref == 'refs/heads/develop' && github.event.pull_request.merged == true
shell: bash
run: |
echo "SNAPSHOT_NAME=${{env.RELEASE_NAME}}" >> "$GITHUB_OUTPUT"
echo "SNAPSHOT_MAVEN_BUILD_PROFILES=${{env.MAVEN_BUILD_PROFILES}}" >> "$GITHUB_OUTPUT"
echo "SNAPSHOT_MVN_DEPLOY_FILE_FLAGS=${{env.MVN_DEPLOY_FILE_FLAGS}}" >> "$GITHUB_OUTPUT"
env:
RELEASE_NAME: "${{github.ref_name}}-SNAPSHOT" # not resolved how to define snapshot name
MAVEN_BUILD_PROFILES: "daml,scala,typescript,golang,csharp8,csharp9,kotlin,python,gpg,excel"
MVN_DEPLOY_FILE_FLAGS: "${{env.MVN_BUILD_FLAGS}} ${{env.MVN_DEPLOY_FLAGS}} -Durl=https://oss.sonatype.org/content/repositories/snapshots -DrepositoryId=ossrh"

build:
needs: setup
runs-on: ubuntu-latest # Not resolved - Maven image required

steps:
- uses: actions/checkout@v4
- name: Build Release CI
if: startsWith(github.event.ref, 'refs/tags')
uses: ./.github/actions/build-migration
with:
build-command: install
release-name: ${{needs.setup.outputs.RELEASE_NAME}}
build-flags: ${{needs.setup.outputs.MVN_BUILD_FLAGS}}
build-profiles: ${{needs.setup.outputs.RELEASE_MVN_DEPLOY_FILE_FLAGS}}
maven-settings: $GITHUB_WORKSPACE/settings.xml
env:
GPG_KEYNAME: ${{secrets.GPG_KEYNAME}}
GPG_PRIVATE_KEY: ${{secrets.GPG_PRIVATE_KEY}}
GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}}
CI_DEPLOY_USERNAME: ${{secrets.CI_DEPLOY_USERNAME}}
CI_DEPLOY_PASSWORD: ${{secrets.CI_DEPLOY_PASSWORD}}

- name: Build Snapshot CI
if: github.ref == 'refs/heads/develop' && github.event.pull_request.merged == true
uses: ./.github/actions/build-migration
with:
build-command: verify
release-name: ${{needs.setup.outputs.SNAPSHOT_NAME}}
build-flags: ${{needs.setup.outputs.MVN_BUILD_FLAGS}}
build-profiles: ${{needs.setup.outputs.SNAPSHOT_MVN_DEPLOY_FILE_FLAGS}}
maven-settings: $GITHUB_WORKSPACE/settings.xml
env:
GPG_KEYNAME: ${{secrets.GPG_KEYNAME}}
GPG_PRIVATE_KEY: ${{secrets.GPG_PRIVATE_KEY}}
GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}}
CI_DEPLOY_USERNAME: ${{secrets.CI_DEPLOY_USERNAME}}
CI_DEPLOY_PASSWORD: ${{secrets.CI_DEPLOY_PASSWORD}}

build:
name: CSharp8 build
shell: bash
runs-on: ubuntu-latest
working-directory: ./rosetta-source/target/classes/cdm/csharp8/NetStandard.2.1
with: dotnet-version '2.1'
strategy:
fail-fast: false
image: mcr.microsoft.com/dotnet/core/sdk:3.1
steps:
- name: build
run: dotnet build Cdm/Cdm.csproj
- name: test
run: dotnet test Test/Test.csproj
- name: publish
run: dotnet publish Cdm/Cdm.csproj -c release -o ./app

build:
name: CSharp9 build
shell: bash
runs-on: ubuntu-latest
working-directory: ./rosetta-source/target/classes/cdm/csharp9/Net.5.0
with: dotnet-version '5.0'
strategy:
fail-fast: false
image: mcr.microsoft.com/dotnet/sdk:5.0
steps:
- name: build
run: dotnet build Cdm/Cdm.csproj
- name: test
run: dotnet test Test/Test.csproj
- name: publish
run: dotnet publish Cdm/Cdm.csproj -c release -o ./app

distribute:
needs: build
runs-on: ubuntu-latest

steps:
# Steps for distribution if needed
- name: Distribute CI
run:
echo "Distribute ci"

finalise:
needs: distribute
runs-on: ubuntu-latest

steps:
# Steps for finalizing the process if needed
- name: Finalize CI
run:
echo "Finalize ci"