From 5260eaa2a54c911bb85224bed0ccdfb113973c90 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 19 Nov 2024 17:06:54 +0000 Subject: [PATCH] Split out some reusable actions --- .github/actions/build/action.yml | 30 ++++++++ .github/actions/integration-test/action.yml | 62 +++++++++++++++ .github/workflows/ci.yaml | 84 --------------------- .github/workflows/ci.yml | 30 ++++++++ 4 files changed, 122 insertions(+), 84 deletions(-) create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/integration-test/action.yml delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/ci.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..a3b62ca --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,30 @@ +name: Build +description: 'Builds the project' +outputs: + version: + description: 'Version that was built' + value: ${{ steps.read-version.outputs.version }} +runs: + using: composite + steps: + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: 'liberica' + java-version: 17 + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 + with: + cache-read-only: false + - name: Build + run: ./gradlew build + shell: bash + - id: read-version + name: Read Version From gradle.properties + run: | + version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties) + echo "Version is $version" + echo "version=$version" >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/actions/integration-test/action.yml b/.github/actions/integration-test/action.yml new file mode 100644 index 0000000..8ff00c9 --- /dev/null +++ b/.github/actions/integration-test/action.yml @@ -0,0 +1,62 @@ +name: Integration Test +description: 'Integration tests the project' +inputs: + signing-key: + description: Key to use to sign artifacts + required: true + signing-passphrase: + description: Passphrase for the signing key + required: true +runs: + using: composite + steps: + - name: Check out action + uses: actions/checkout@v4 + - name: Create artifacts to deploy + run: | + mkdir -p deployment-repository/com/example/module-a/1.0.0-SNAPSHOT + touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar + touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom + touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar + touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar + mkdir -p deployment-repository/com/example/module-b/1.0.0-SNAPSHOT + touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar + touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom + touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar + touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar + shell: bash + - name: Run action + uses: ./ + id: run + with: + uri: 'http://artifactory:8081/artifactory' + username: 'admin' + password: 'password' + build-name: ${{github.action}} + repository: 'example-repo-local' + folder: 'deployment-repository' + signing-key: ${{ inputs.signing-key }} + signing-passphrase: ${{ inputs.signing-passphrase }} + artifact-properties: | + :/**/*.jar:not-jar=true + /**/module-a-*::a=alpha + /**/module-b-*::b=bravo,c=charlie + - name: Download artifacts + run: | + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar.asc + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom.asc + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar.asc + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar.asc + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar.asc + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom.asc + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar.asc + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar + wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar.asc + shell: bash diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index c4b2a3a..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,84 +0,0 @@ -name: CI -on: - - push -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} -jobs: - build: - name: 'Build' - runs-on: 'ubuntu-latest' - steps: - - name: Set up Java - uses: actions/setup-java@v4 - with: - distribution: 'liberica' - java-version: 17 - - name: Check out code - uses: actions/checkout@v4 - - name: Set up Gradle - uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 - with: - cache-read-only: false - - name: Build - id: build - run: ./gradlew build - integration-test: - runs-on: ubuntu-latest - name: 'Integration test' - services: - artifactory: - image: docker.bintray.io/jfrog/artifactory-oss:7.12.10 - ports: - - 8081:8081 - steps: - - name: Check out action - uses: actions/checkout@v4 - - name: Create artifacts to deploy - run: | - mkdir -p deployment-repository/com/example/module-a/1.0.0-SNAPSHOT - touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar - touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom - touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar - touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar - mkdir -p deployment-repository/com/example/module-b/1.0.0-SNAPSHOT - touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar - touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom - touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar - touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar - - name: Run action - uses: ./ - id: run - with: - uri: 'http://artifactory:8081/artifactory' - username: 'admin' - password: 'password' - build-name: ${{github.action}} - repository: 'example-repo-local' - folder: 'deployment-repository' - signing-key: ${{ secrets.INTEGRATION_TEST_SIGNING_KEY }} - signing-passphrase: ${{ secrets.INTEGRATION_TEST_SIGNING_PASSPHRASE }} - artifact-properties: | - :/**/*.jar:not-jar=true - /**/module-a-*::a=alpha - /**/module-b-*::b=bravo,c=charlie - env: - ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }} - - name: Download artifacts - run: | - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar.asc - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom.asc - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar.asc - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar.asc - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar.asc - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom.asc - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar.asc - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar - wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar.asc - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3fd5902 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI +on: + - push +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} +jobs: + build: + name: 'Build' + runs-on: 'ubuntu-latest' + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Build + uses: ./.github/actions/build + integration-test: + name: 'Integration test' + runs-on: ubuntu-latest + services: + artifactory: + image: docker.bintray.io/jfrog/artifactory-oss:7.12.10 + ports: + - 8081:8081 + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Integration test + uses: ./.github/actions/integration-test + with: + signing-key: ${{ secrets.INTEGRATION_TEST_SIGNING_KEY }} + signing-passphrase: ${{ secrets.INTEGRATION_TEST_SIGNING_PASSPHRASE }}