update #18
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 | |
| on: [push] | |
| jobs: | |
| ###<<<delete-on-init | |
| init: | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_TOKEN: "${{secrets.WORKFLOW_TOKEN}}" | |
| steps: | |
| - name: "checkout" | |
| uses: actions/checkout@v1 | |
| - name: "attach git head" | |
| run: git checkout "${GITHUB_REF#refs/heads/}" | |
| - name: "get buildtools" | |
| uses: ModelingValueGroup/buildtools@master | |
| - name: "if only one commit: init the repo" | |
| run: | | |
| if [[ "$(git rev-list --all --count)" == 1 ]]; then | |
| echo "::info::INIT TEMPLATE REPO" | |
| repo="${GITHUB_REPOSITORY/*\//}" | |
| sed -i '/###delete-on-init$/d;/^###<<<delete-on-init/,/^###delete-on-init>>>/d' .github/workflows/build.yaml | |
| sed -i "s|helloworld|$repo|g" project.sh | |
| sed -i "s|template-java|$repo|g" build.xml | |
| sed -i "s|template-java|$repo|g" pom.xml | |
| . <(java -jar ~/buildtools.jar) | |
| pushBackToGithub | |
| fi | |
| ###delete-on-init>>> | |
| build: | |
| needs: init ###delete-on-init | |
| if: github.repository == 'ModelingValueGroup/template-java' ###delete-on-init | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}" | |
| steps: | |
| - name: "checkout" | |
| uses: actions/checkout@v1 | |
| - name: "attach git head" | |
| run: git checkout "${GITHUB_REF#refs/heads/}" | |
| - name: "setup JDK" | |
| uses: actions/setup-java@v1 | |
| with: | |
| java-version: 17 | |
| - name: "get generic mvg-info" | |
| uses: ModelingValueGroup/generic-info@master | |
| - name: "get buildtools" | |
| uses: ModelingValueGroup/buildtools@master | |
| - name: "prepare ant" | |
| run: | | |
| cat <<EOF >build.properties | |
| jdk.home.11=$JAVA_HOME | |
| path.variable.maven_repository=$HOME/.m2/repository | |
| EOF | |
| - name: "(re)generate some files" | |
| run: | | |
| . <(java -jar ~/buildtools.jar) | |
| generateAll | |
| correctEols | |
| correctHeaders header | |
| - name: "push changes back to github" | |
| run: | | |
| . <(java -jar ~/buildtools.jar) | |
| pushBackToGithub | |
| - name: "download dependencies (as mentioned in pom)" | |
| run: | | |
| . <(java -jar ~/buildtools.jar) | |
| getAllDependencies "${{secrets.SCALEWAY_ACCESS_KEY}}" "${{secrets.SCALEWAY_SECRET_KEY}}" | |
| installJunitlauncher | |
| - name: "build" | |
| run: ant | |
| - name: "test" | |
| run: | | |
| if ! ant test; then | |
| for i in TEST-*.xml; do | |
| echo "=============== $i" | |
| sed "s/^/>> /" $i | |
| done | |
| exit 42 | |
| fi | |
| - name: "generate javadoc" | |
| run: ant javadoc | |
| - name: "publish action-artifact jar" | |
| uses: actions/upload-artifact@v1 | |
| with: | |
| name: helloworld.jar | |
| path: out/artifacts/helloworld.jar | |
| - name: "publish action-artifact sources" | |
| uses: actions/upload-artifact@v1 | |
| with: | |
| name: helloworld-sources.jar | |
| path: out/artifacts/helloworld-sources.jar | |
| - name: "publish action-artifact javadoc" | |
| uses: actions/upload-artifact@v1 | |
| with: | |
| name: helloworld-javadoc.jar | |
| path: out/artifacts/helloworld-javadoc.jar | |
| - name: "publish action-artifact test-results" | |
| uses: actions/upload-artifact@v1 | |
| with: | |
| name: helloworld-testresults.jar | |
| path: out/artifacts/helloworld-testresults.jar | |
| - name: "if NOT master: saving snapshots for other projects on this branch" | |
| if: github.ref != 'refs/heads/master' | |
| run: | | |
| . <(java -jar ~/buildtools.jar) | |
| storeMyBranchSnapshots | |
| - name: "if master: tag with version" | |
| if: github.ref == 'refs/heads/master' | |
| run: | | |
| . <(java -jar ~/buildtools.jar) | |
| setVersionTag | |
| - name: "if master: publish maven-artifacts (jar/pom/sources/javadoc)" | |
| uses: ModelingValueGroup/upload-maven-package-action@master | |
| if : github.ref == 'refs/heads/master' | |
| with: | |
| file : "out/artifacts/helloworld.jar" |