From 75af3ff9b2264c8c627a7ca676dd6d45788616bf Mon Sep 17 00:00:00 2001 From: Joseph Date: Thu, 28 May 2026 08:20:13 +0100 Subject: [PATCH] Migrate CI from Travis CI to GitHub Actions Replace three outdated workflow files (build.yml, deploy.yml, pr-build.yml) and .travis.yml with a single consolidated .github/workflows/ci.yml that: - Uses actions/checkout@v4 and actions/setup-java@v4 (current best practice) - Upgrades from Java 17 to Java 21 to match the Travis CI configuration - Uses setup-java built-in Maven cache instead of a separate cache step - Restores GPG key import in the deploy job (was commented out in old deploy.yml) - Adds a repository owner guard on deploy to prevent forks from triggering releases - Triggers on push to main, all tag pushes, and pull_request to main Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/build.yml | 35 ---------------------- .github/workflows/ci.yml | 53 ++++++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 24 --------------- .github/workflows/pr-build.yml | 26 ----------------- .travis.yml | 16 ---------- 5 files changed, 53 insertions(+), 101 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/pr-build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index decd127..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Build -on: - push: - branches: - - main -jobs: - build: - name: Build - runs-on: ubuntu-latest - if: github.repository_owner == 'alfasoftware' - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 17 - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify # org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -X -Pcoverage diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9fc1e71 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: [main] + tags: ['*'] + pull_request: + branches: [main] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: 'maven' + + - name: Run tests + run: mvn clean verify + + deploy: + name: Deploy + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.repository_owner == 'alfasoftware' + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: 'maven' + + - name: Import GPG keys + run: | + echo "$GPG_SECRET_KEYS" | base64 --decode | gpg --batch --import + echo "$GPG_OWNERTRUST" | base64 --decode | gpg --batch --import-ownertrust + env: + GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }} + GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }} + + - name: Deploy to Maven Central + run: mvn clean deploy --settings .maven-settings.xml -B -U -Prelease diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 95a2bd8..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Publish package to the Maven Central Repository -on: - push: -# release: -# types: [edited] -jobs: - release: - name: "Deploy" - runs-on: ubuntu-latest - steps: - - name: Check out Git repository - uses: actions/checkout@v2 - - - name: Install Java and Maven - uses: actions/setup-java@v1 - with: - java-version: 17 - -# - name: foo -# run: echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust -# - name: bar -# run: echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import - - name: "Maven Deploy" - run: mvn clean deploy --settings .maven-settings.xml -B -U -Prelease diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml deleted file mode 100644 index 4fbd7a0..0000000 --- a/.github/workflows/pr-build.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 17 - uses: actions/setup-java@v1 - with: - java-version: 17 - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - run: mvn clean verify diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 87b4393..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: java -dist: noble -jdk: openjdk21 -jobs: - include: - - if: repo = alfasoftware/astra AND head_repo = alfasoftware/astra AND type = pull_request - name: "Test" - script: - - git fetch --quiet - - mvn clean verify - - if: repo = alfasoftware/astra AND (branch = main OR tag IS present) AND NOT type = pull_request - name: "Deploy" - script: - - echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --batch --import - - echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --batch --import-ownertrust - - mvn clean deploy --settings .maven-settings.xml -B -U -Prelease