diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 78bf2e38..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,122 +0,0 @@ -version: 2.1 - -orbs: - queue: eddiewebb/queue@volatile - -aliases: - - &sonar-scan - name: Sonar scan - command: | - mvn -s .circleci/settings.xml \ - org.jacoco:jacoco-maven-plugin:prepare-agent verify \ - org.jacoco:jacoco-maven-plugin:report sonar:sonar \ - -Dmaven.main.skip \ - -DskipTests \ - -Dsonar.projectKey=entur_${CIRCLE_PROJECT_REPONAME} \ - -Dsonar.organization=${SONAR_ORG} \ - -Dsonar.projectName=${CIRCLE_PROJECT_REPONAME} \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.token=${ENTUR_SONAR_PASSWORD} - - &jfrog-login - name: Rename jfrog environment variable for maven setting.xml - command: | - echo "export JFROG_USER=$ARTIFACTORY_USER" >> $BASH_ENV - echo "export JFROG_PASS=$ARTIFACTORY_PASSWORD" >> $BASH_ENV - - &release - name: Release - command: | - echo "Start release" - git config --global user.email "circleci@entur.no" - git config --global user.name "circleci" - git checkout master - mvn gitflow:release-start gitflow:release-finish -DskipTests=true -Prelease -DpostReleaseGoals=deploy -DargLine='-Prelease -DskipTests -s .circleci/settings.xml' -B -s .circleci/settings.xml - - &import_gpg_key - name: Configure GPG private key for signing project artifacts in OSS Sonatype - command: | - echo $SONATYPE_GPG_KEY_BASE64 | base64 --decode | gpg --batch --no-tty --import --yes - -jobs: - test: - docker: - - image: cimg/openjdk:17.0.11 - auth: - username: $DOCKERHUB_LOGIN - password: $DOCKERHUB_PASSWORD - environment: - MAVEN_OPTS: -Xmx3G - steps: - - checkout - - restore_cache: - keys: - - dep-cache-{{ checksum "pom.xml" }} - # fallback to the most recent cache if there is no exact match for this pom.xml - - dep-cache- - - run: - name: Download Maven settings - command: wget https://raw.githubusercontent.com/entur/circleci-toolbox-image-java11/master/tools/m2/settings.xml -O .circleci/settings.xml - - run: *jfrog-login - - run: - name: Refresh cache - # Use forked version of the dependency plugin to handle correctly inter-module dependencies (https://issues.apache.org/jira/browse/MDEP-568) - command: mvn com.offbytwo.maven.plugins:maven-dependency-plugin:3.1.1.MDEP568:go-offline -DexcludeGroupIds=org.entur.ror.helpers -s .circleci/settings.xml - - save_cache: - paths: - - ~/.m2 - key: dep-cache-{{ checksum "pom.xml" }} - # Cannot use -o because of snapshot dependencies. - - run: - name: Run Maven verify - command: mvn verify -s .circleci/settings.xml - - run: *sonar-scan - - run: - name: Save test results - command: | - mkdir -p ~/junit/ - find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/junit/ \; - when: always - - store_test_results: - path: ~/junit - - store_artifacts: - path: ~/junit - - persist_to_workspace: - root: ~/project - paths: - - target - - .circleci - - deploy-nexus: - docker: - - image: cimg/openjdk:17.0.11 - auth: - username: $DOCKERHUB_LOGIN - password: $DOCKERHUB_PASSWORD - environment: - MAVEN_OPTS: -Xmx3G - steps: - - run: git config --global user.email "circleci@entur.no" - - run: git config --global user.name "circleci" - - checkout - - restore_cache: - keys: - - dep-cache-{{ checksum "pom.xml" }} - # fallback to the most recent cache if there is no exact match for this pom.xml - - dep-cache- - - attach_workspace: - at: ~/project - - run: *jfrog-login - - run: *import_gpg_key - - run: *release - -workflows: - version: 2 - build_test_deploy: - jobs: - - test: - context: global - - deploy-nexus: - context: global - requires: - - test - filters: - branches: - only: master diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..4c5b3561 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,101 @@ +name: Build and push +on: + push: + branches: + - main + pull_request: + branches: + - master +env: + JFROG_USER: ${{ secrets.ARTIFACTORY_AUTH_USER }} + JFROG_PASS: ${{ secrets.ARTIFACTORY_AUTH_TOKEN }} + SONATYPE_GPG_KEY_BASE64: ${{ secrets.SONATYPE_GPG_KEY_BASE64 }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_GPG_KEY_PASSWORD: ${{ secrets.SONATYPE_GPG_KEY_PASSWORD }} + +jobs: + maven-package: + if: "!contains(github.event.head_commit.message, 'ci skip')" + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Copy maven settings + run: | + wget https://raw.githubusercontent.com/entur/ror-maven-settings/master/.m2/settings.xml -O .github/workflows/settings.xml + - uses: actions/setup-java@v4 + with: + java-version: 17.0.13 + distribution: liberica + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + ${{ runner.os }}-maven- + ${{ runner.os }}- + + - name: Run maven build + run: mvn package -s .github/workflows/settings.xml -PprettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm + - name: Sonar Scan + env: + SONAR_TOKEN: ${{ secrets.ENTUR_SONAR_PASSWORD }} + SONAR_PROJECT_NAME: ${{ github.event.repository.name }} + SONAR_PROJECT_KEY: entur_${{ github.event.repository.name }} + run: | + mvn -s .github/workflows/settings.xml \ + org.jacoco:jacoco-maven-plugin:prepare-agent verify \ + org.jacoco:jacoco-maven-plugin:report sonar:sonar \ + -Dmaven.main.skip \ + -DskipTests \ + -Dsonar.projectKey=${SONAR_PROJECT_KEY} \ + -Dsonar.organization=enturas-github \ + -Dsonar.projectName=${SONAR_PROJECT_NAME} \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.token=${SONAR_TOKEN} + - name: Upload artifact + uses: actions/upload-artifact@v4.4.3 + with: + path: target/*.jar + deploy-maven-central: + if: github.repository_owner == 'entur' && github.event_name == 'push' && github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'ci skip') + needs: [maven-package] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Copy maven settings + run: | + wget https://raw.githubusercontent.com/entur/ror-maven-settings/master/.m2/settings.xml -O .github/workflows/settings.xml + - uses: actions/setup-java@v4 + with: + java-version: 17.0.13 + distribution: liberica + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + ${{ runner.os }}-maven- + ${{ runner.os }}- + + - name: Release to Maven Central + run: | + echo "Start release" + echo $SONATYPE_GPG_KEY_BASE64 | base64 --decode | gpg --batch --no-tty --import --yes + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git checkout master + mvn gitflow:release-start gitflow:release-finish \ + -DskipTests=true \ + -Prelease \ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ + -DpostReleaseGoals=deploy \ + -DargLine='-Prelease -DskipTests -s .github/workflows/settings.xml' -B -s .github/workflows/settings.xml