diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 93e4662..dc91ac6 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -3,9 +3,9 @@ name: FMI to VDM -on: [workflow_dispatch, push, pull_request] +on: [ workflow_dispatch, push, pull_request ] env: - JAVA_VERSION: 1.8 + JAVA_VERSION: 11.0.3 SERVER_ID: ossrh jobs: @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v2 - name: Set up JDK @@ -29,31 +29,31 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - id: install-secret-key - name: Install gpg secret key - run: | - cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import - gpg --list-secret-keys --keyid-format LONG + - id: install-secret-key + name: Install gpg secret key + run: | + cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import + gpg --list-secret-keys --keyid-format LONG -# - name: Configure deploy for snapshots -# if: github.ref == 'refs/heads/development' -# run: echo "SERVER_ID=artifactory-into-cps-snapshots" >> $GITHUB_ENV - - name: Environment variables - run: echo ${{ env.SERVER_ID }} + # - name: Configure deploy for snapshots + # if: github.ref == 'refs/heads/development' + # run: echo "SERVER_ID=artifactory-into-cps-snapshots" >> $GITHUB_ENV + - name: Environment variables + run: echo ${{ env.SERVER_ID }} - - name: Set up JDK - uses: actions/setup-java@v1 - with: - java-version: ${{ env.JAVA_VERSION }} - server-id: ${{ env.SERVER_ID }} - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - gpg-passphrase: MAVEN_GPG_PASSPHRASE - - name: Deploy - run: mvn -B deploy -Psonatype - env: - MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ env.JAVA_VERSION }} + server-id: ${{ env.SERVER_ID }} + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Deploy + run: mvn -B deploy -Psonatype + env: + MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c361d6e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,300 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Release new version + +on: + workflow_dispatch: + inputs: + releaseversion: + description: 'Release version' +# required: true +# default: '2.4.0' +# snapshotversion: +# description: 'Next snapshot version' +# required: true +# default: '2.4.1' + +env: + JAVA_VERSION: 11.0.3 + SERVER_ID: ossrh + + + + +jobs: + + version_change: + name: Create version and tag + runs-on: ubuntu-latest + outputs: + build_tag: ${{ steps.tagging.outputs.build_tag }} # map step output to job output + build_tag_created: ${{ steps.tagging.outputs.build_tag_created }} + build_version: ${{ steps.tagging.outputs.build_version }} # map step output to job output + build_branch: ${{ steps.tagging.outputs.build_branch }} + previous_release_tag: ${{ steps.tagging.outputs.previous_release_tag }} + steps: + - name: Set up Java + uses: actions/setup-java@v1 + with: + java-version: ${{ env.JAVA_VERSION }} + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: setup git config + run: | + # setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default + git config user.name "GitHub Actions Bot" + git config user.email "<>" + + - name: Maven download + run: mvn validate dependency:resolve-plugins -B --quiet + + - name: Set release version + id: tagging + run: | + # make sure we are at the head of development + NEW_RELEASE_VERSION=${{ github.event.inputs.releaseversion }} + echo "Input version is $NEW_RELEASE_VERSION" + # remove all but the release version + mvn -B --quiet versions:set-property -Dproperty=changelist "-DnewVersion=" + mvn -B --quiet versions:set-property -Dproperty=sha1 "-DnewVersion=" + # detect if a override version is given + if [ "$NEW_RELEASE_VERSION" == "" ]; then + echo "Input version not set. Use current version" + NEW_RELEASE_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) + fi + # set the version to be released + NEW_RELEASE_TAG="Release/${NEW_RELEASE_VERSION}" + NEW_RELEASE_BRANCH="prepare-release/${NEW_RELEASE_VERSION}" + + echo "::set-output name=build_tag::${NEW_RELEASE_TAG}" + echo "::set-output name=build_version::${NEW_RELEASE_VERSION}" + echo "::set-output name=build_branch::${NEW_RELEASE_BRANCH}" + PREVIOUS_RELEASE_TAG=$(git tag | sort -V | tail -1) + echo "::set-output name=previous_release_tag::${PREVIOUS_RELEASE_TAG}" + + + echo "release version is $NEW_RELEASE_VERSION" + echo "Tag release version is now $NEW_RELEASE_TAG" + mvn -B --quiet versions:set-property -Dproperty=revision "-DnewVersion=${NEW_RELEASE_VERSION}" + git checkout -b $NEW_RELEASE_BRANCH + git push -f --set-upstream origin $NEW_RELEASE_BRANCH + git add pom.xml + git commit -m "New release version ${NEW_RELEASE_VERSION}" + git tag -a "${NEW_RELEASE_TAG}" -m "Release version ${NEW_RELEASE_VERSION}" + git push origin "${NEW_RELEASE_TAG}" + echo "::set-output name=build_tag_created::YES" + # prepare next snapshot for development + mvn -B --quiet ci-friendly-flatten:version -Dprefix.regex="Release/*" + SNAPSHOTVERSION=$(cat revision.txt) + mvn -B --quiet versions:set-property -Dproperty=revision "-DnewVersion=$SNAPSHOTVERSION" + mvn -B --quiet versions:set-property -Dproperty=changelist "-DnewVersion=-SNAPSHOT" + mvn -B --quiet versions:set-property -Dproperty=sha1 "-DnewVersion=" + git add pom.xml + git commit -m "Next snapshot version $SNAPSHOTVERSION" + git push + + + build: + name: Java and Native Compilation + runs-on: ${{ matrix.os }} + needs: version_change + + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] # ubuntu-latest, , macos-latest + platform: [ x64 ] #x32, x64 ] + exclude: + - os: macos-latest + platform: x32 + steps: + + + - uses: actions/checkout@v2 + with: + submodules: 'true' + ref: ${{ needs.version_change.outputs.build_tag }} + + - name: Set up Java x64 + if: matrix.platform == 'x64' + uses: actions/setup-java@v1 + with: + java-version: ${{ env.JAVA_VERSION }} + architecture: x64 + + - name: Set up Java x32 + if: matrix.platform == 'x86' + uses: actions/setup-java@v1 + with: + java-version: ${{ env.JAVA_VERSION }} + architecture: x32 + + + - name: Maven download + run: mvn validate dependency:resolve-plugins -Psonatype -Prelease -B --quiet + + - name: Maven Build + run: mvn -B package -Psonatype -Prelease --file pom.xml "-Dmaven.test.skip=true" + + final: + name: Build and Deploy Combined Release + runs-on: ubuntu-latest + + needs: [ version_change , build ] + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + ref: ${{ needs.version_change.outputs.build_tag }} + + - id: install-secret-key + name: Install gpg secret key + run: | + cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import + gpg --list-secret-keys --keyid-format LONG + + - name: Environment variables + run: echo ${{ env.SERVER_ID }} + + + - name: Set up Java x64 + if: matrix.platform == 'x64' + uses: actions/setup-java@v1 + with: + java-version: ${{ env.JAVA_VERSION }} + architecture: x64 + + - name: Set up Java x32 + if: matrix.platform == 'x86' + uses: actions/setup-java@v1 + with: + java-version: ${{ env.JAVA_VERSION }} + architecture: x32 + + - name: Deploy server + uses: actions/setup-java@v1 + with: + java-version: ${{ env.JAVA_VERSION }} + server-id: ${{ env.SERVER_ID }} + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + + - name: Maven download + run: mvn validate dependency:resolve-plugins -Psonatype -Prelease -B --quiet + + - name: Maven Build Final + run: mvn -B package -Psonatype -Prelease --file pom.xml -Dmaven.test.skip=true + + - name: Maven Deploy RELEASE + # If autorelease is false then it must be released from here: https://oss.sonatype.org/#stagingRepositories -DautoReleaseAfterClose=true + run: mvn -B deploy -Dchangelist= -Dsha1= -Dmaven.test.skip=true -DskipITs -fae -Psonatype + env: + MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + + + - name: Create changelog config + run: echo '{"max_back_track_time_days":1095}' > configuration.json + + - name: Generate changelog + id: changelog + uses: mikepenz/release-changelog-builder-action@v2.9.0 + with: + configuration: "configuration.json" + toTag: ${{ needs.version_change.outputs.build_tag }} + fromTag: ${{ needs.version_change.outputs.previous_release_tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.version_change.outputs.build_tag }} + release_name: ${{ needs.version_change.outputs.build_tag }} + body: | + Grab the new version from Maven central https://search.maven.org/artifact/org.into-cps.fmi/jnifmuapi/${{ needs.version_change.outputs.build_version }}/jar: + + ``` + + org.into-cps.vdmcheck.fmi2 + vdmcheck2 + ${{ needs.version_change.outputs.build_version }} + + ``` + + ### Things that changed in this release + ${{ steps.changelog.outputs.changelog }} + draft: true + prerelease: false + + - name: Upload Release Asset - VDMCheck2 + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: fmi2/vdmcheck/target/FMI2-vdmcheck-${{ needs.version_change.outputs.build_version }}-distribution.zip + asset_name: FMI2-vdmcheck-${{ needs.version_change.outputs.build_version }}-distribution.zip + asset_content_type: application/zip + + - name: Upload Release Asset - VDMCheck3 + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: fmi3/vdmcheck/target/FMI3-vdmcheck-${{ needs.version_change.outputs.build_version }}-distribution.zip + asset_name: FMI3-vdmcheck-${{ needs.version_change.outputs.build_version }}-distribution.zip + asset_content_type: application/zip + + + rollback: + name: Rollback on error + runs-on: ubuntu-latest + + needs: [ version_change , build, final ] + if: always() && (needs.version_change.result == 'failure' || needs.build.result == 'failure' || needs.final.result == 'failure') + steps: + - uses: actions/checkout@v2 + + - name: Rolling back tag + continue-on-error: true + if: needs.version_change.outputs.build_tag_created == 'YES' + # we don't want to accidentally delete an existing tag from an existing release + run: git push --delete origin ${{ needs.version_change.outputs.build_tag }} + + - name: Rolling back branch + continue-on-error: true + run: git push origin --delete ${{ needs.version_change.outputs.build_branch }} + + cleanup: + name: Update development and master with new release + runs-on: ubuntu-latest + + needs: [ final,version_change ] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Merging release + run: | + git fetch origin ${{ needs.version_change.outputs.build_branch }} + git checkout development + git merge origin/${{ needs.version_change.outputs.build_branch }} + git push + git checkout master + git reset --hard ${{ needs.version_change.outputs.build_tag }} + git push -f origin master diff --git a/.gitignore b/.gitignore index 76c9b74..6559572 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ generated .generated /install.sh +.ci-friendly-pom.xml diff --git a/fmi2/cosim-model/pom.xml b/fmi2/cosim-model/pom.xml index 0498a18..fbbff02 100644 --- a/fmi2/cosim-model/pom.xml +++ b/fmi2/cosim-model/pom.xml @@ -3,7 +3,8 @@ org.into-cps.vdmcheck fmi2 - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck.fmi2 diff --git a/fmi2/cosim2vdm/pom.xml b/fmi2/cosim2vdm/pom.xml index 694d6d0..2f39282 100644 --- a/fmi2/cosim2vdm/pom.xml +++ b/fmi2/cosim2vdm/pom.xml @@ -6,7 +6,8 @@ org.into-cps.vdmcheck fmi2 - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck.fmi2 diff --git a/fmi2/pom.xml b/fmi2/pom.xml index d52a445..bef5bbc 100644 --- a/fmi2/pom.xml +++ b/fmi2/pom.xml @@ -6,7 +6,7 @@ org.into-cps vdmcheck - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} ../pom.xml diff --git a/fmi2/static-model/pom.xml b/fmi2/static-model/pom.xml index bb456cd..10c79c8 100644 --- a/fmi2/static-model/pom.xml +++ b/fmi2/static-model/pom.xml @@ -3,7 +3,8 @@ org.into-cps.vdmcheck fmi2 - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck.fmi2 diff --git a/fmi2/vdmcheck/pom.xml b/fmi2/vdmcheck/pom.xml index 6eb75cf..2a85cf1 100644 --- a/fmi2/vdmcheck/pom.xml +++ b/fmi2/vdmcheck/pom.xml @@ -1,80 +1,83 @@ - - 4.0.0 + + 4.0.0 - - org.into-cps.vdmcheck - fmi2 - 1.1.3-SNAPSHOT - + + org.into-cps.vdmcheck + fmi2 + ${revision}${sha1}${changelist} + ../pom.xml + - org.into-cps.vdmcheck.fmi2 - vdmcheck2 + org.into-cps.vdmcheck.fmi2 + vdmcheck2 - - yyMMdd - + + yyMMdd + - - - org.into-cps.vdmcheck.fmi2 - static-model - ${project.version} - - - org.into-cps.vdmcheck - xsd2vdm - - - dk.au.ece.vdmj - vdmj - - - dk.au.ece.vdmj - annotations - - - junit - junit - 4.8.2 - test - - - - + + + org.into-cps.vdmcheck.fmi2 + static-model + ${project.version} + + + org.into-cps.vdmcheck + xsd2vdm + + + dk.au.ece.vdmj + vdmj + + + dk.au.ece.vdmj + annotations + + + junit + junit + 4.8.2 + test + + + + - - maven-jar-plugin - - - - VDMCheck - ${project.version} build ${maven.build.timestamp} - . - - - - ${project.artifactId}-${project.version}-${maven.build.timestamp} - - - - - maven-assembly-plugin - - - src/assembly/assembly.xml - - FMI2-vdmcheck-${project.version}-${maven.build.timestamp} - - - - package - - single - - - - - - + + maven-jar-plugin + + + + VDMCheck + ${project.version} build ${maven.build.timestamp} + + . + + + + ${project.artifactId}-${project.version} + + + + + maven-assembly-plugin + + + src/assembly/assembly.xml + + FMI2-vdmcheck-${project.version} + + + + package + + single + + + + + + \ No newline at end of file diff --git a/fmi3/ls-bus-model/pom.xml b/fmi3/ls-bus-model/pom.xml index d096c12..8b744af 100644 --- a/fmi3/ls-bus-model/pom.xml +++ b/fmi3/ls-bus-model/pom.xml @@ -3,7 +3,8 @@ org.into-cps.vdmcheck fmi3 - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck.fmi3 diff --git a/fmi3/pom.xml b/fmi3/pom.xml index a74ce96..57bbec1 100644 --- a/fmi3/pom.xml +++ b/fmi3/pom.xml @@ -6,7 +6,7 @@ org.into-cps vdmcheck - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} ../pom.xml diff --git a/fmi3/rule-model/pom.xml b/fmi3/rule-model/pom.xml index 9f48650..37c0f73 100644 --- a/fmi3/rule-model/pom.xml +++ b/fmi3/rule-model/pom.xml @@ -3,7 +3,8 @@ org.into-cps.vdmcheck fmi3 - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck.fmi3 diff --git a/fmi3/static-model/pom.xml b/fmi3/static-model/pom.xml index 4c96e5d..d514c21 100644 --- a/fmi3/static-model/pom.xml +++ b/fmi3/static-model/pom.xml @@ -3,7 +3,8 @@ org.into-cps.vdmcheck fmi3 - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck.fmi3 diff --git a/fmi3/vdmcheck/pom.xml b/fmi3/vdmcheck/pom.xml index e959b8d..7768562 100644 --- a/fmi3/vdmcheck/pom.xml +++ b/fmi3/vdmcheck/pom.xml @@ -3,7 +3,7 @@ org.into-cps.vdmcheck fmi3 - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} ../pom.xml @@ -59,7 +59,7 @@ - ${project.artifactId}-${project.version}-${maven.build.timestamp} + ${project.artifactId}-${project.version} @@ -76,7 +76,7 @@ src/assembly/assembly.xml - FMI3-vdmcheck-${project.version}-${maven.build.timestamp} + FMI3-vdmcheck-${project.version} diff --git a/fmuReader/pom.xml b/fmuReader/pom.xml index d45931e..88183e0 100644 --- a/fmuReader/pom.xml +++ b/fmuReader/pom.xml @@ -6,7 +6,8 @@ org.into-cps vdmcheck - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck diff --git a/pom.xml b/pom.xml index 4be7eaf..199dadc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -14,20 +15,25 @@ org.into-cps vdmcheck - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + pom UTF-8 - yyMMdd - + yyMMdd + + 1.1.3 + -SNAPSHOT + + Maven Central Snapshots - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots @@ -39,30 +45,30 @@ fmuReader - - - - dk.au.ece.vdmj - vdmj - 4.4.6 - - - dk.au.ece.vdmj - annotations - 4.4.6 - - - org.into-cps.vdmcheck - xsd2vdm - ${project.version} - - - org.into-cps.vdmcheck - fmuReader - ${project.version} - - - + + + + dk.au.ece.vdmj + vdmj + 4.4.6 + + + dk.au.ece.vdmj + annotations + 4.4.6 + + + org.into-cps.vdmcheck + xsd2vdm + ${project.version} + + + org.into-cps.vdmcheck + fmuReader + ${project.version} + + + @@ -114,14 +120,14 @@ - - org.apache.maven.plugins - maven-release-plugin - 3.0.0-M1 - - Release/@{project.version} - - + + org.apache.maven.plugins + maven-release-plugin + 3.0.0-M1 + + Release/@{project.version} + + @@ -186,12 +192,23 @@ + + com.outbrain.swinfra + ci-friendly-flatten-maven-plugin + 1.0.14 + + + + clean + flatten + + + + - - git@github.com:INTO-CPS-Association/FMI-VDM-Model scm:git:git//github.com/INTO-CPS-Association/FMI-VDM-Model @@ -220,7 +237,6 @@ 2020 - sonatype @@ -277,6 +293,34 @@ + + release + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0 + + + enforce-no-snapshots + + enforce + + + + + No Snapshots Allowed! + + + true + + + + + + + au diff --git a/xsd2vdm/pom.xml b/xsd2vdm/pom.xml index 958115b..34b4fbe 100644 --- a/xsd2vdm/pom.xml +++ b/xsd2vdm/pom.xml @@ -6,7 +6,8 @@ org.into-cps vdmcheck - 1.1.3-SNAPSHOT + ${revision}${sha1}${changelist} + ../pom.xml org.into-cps.vdmcheck