From 00378d102ce8918472930b0c3bc002a7c09091b7 Mon Sep 17 00:00:00 2001 From: Ian Roberts Date: Fri, 18 Aug 2023 18:51:04 +0100 Subject: [PATCH] Workflow to deploy snapshot distro to repo.gate.ac.uk --- .github/workflows/ci.yaml | 117 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..4f1aa96 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,117 @@ +name: CI + +on: + push: + branches: + - master + +# Prevent concurrent builds of the same branch - a new push will cancel the +# running workflow and start another +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + checks: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Master Branch + uses: actions/checkout@v3 + + - name: Setup Pages + uses: actions/configure-pages@v2 + continue-on-error: true + # This step may error out when run in a fork that doesn't have pages + # enabled - if this happens, run the rest but skip anything that + # involves publishing to pages. The last thing configure-pages does + # is set an environment variable GITHUB_PAGES=true which is visible + # to subsequent steps, so we can condition on that. + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'zulu' + cache: maven + + # Override http://repo.gate.ac.uk to use https:// instead + - name: Configure Maven settings + uses: whelk-io/maven-settings-xml-action@v21 + with: + mirrors: > + [ + { + "id": "gate.ac.uk-https", + "name": "GATE repo (secure)", + "mirrorOf": "gate.ac.uk", + "url": "https://repo.gate.ac.uk/content/groups/public/" + } + ] + repositories: > + [ + { + "id": "central", + "name": "Maven Central", + "url": "https://repo1.maven.org/maven2", + "releases": { + "enabled": "true" + }, + "snapshots": { + "enabled": "false" + } + } + ] + plugin_repositories: > + [ + { + "id": "central", + "name": "Maven Central", + "url": "https://repo1.maven.org/maven2", + "releases": { + "enabled": "true" + }, + "snapshots": { + "enabled": "false" + } + } + ] + servers: > + [ + { + "id": "gate.snapshots", + "username": "${{ secrets.GATE_REPO_USERNAME }}", + "password": "${{ secrets.GATE_REPO_PASSWORD }}" + } + ] + + - name: Build with Maven + run: mvn --batch-mode -e clean install + + + # Only do the deply and distro if we're in the main GateNLP repo, not a fork + - name: Deploy api to repo.gate.ac.uk + if: github.repository == 'GateNLP/gcp' && github.ref == 'refs/heads/master' + working-directory: ./api + run: mvn --batch-mode -e -Dmaven.test.skip=true source:jar javadoc:jar deploy + + - name: Build and deploy distribution + if: github.repository == 'GateNLP/gcp' && github.ref == 'refs/heads/master' + working-directory: ./distribution + run: mvn --batch-mode deploy + + # We want to avoid cacheing -SNAPSHOT dependencies from our local maven + # cache, to ensure that we always go out and check for them again at the + # next build in case they have changed. + - name: Delete snapshots from m2 repository + if: always() + run: | + find ~/.m2/repository -name \*-SNAPSHOT -type d -exec rm -rf {} \+ || : +