From bf37f63690e70d8f4ffd7a0f1da3e1566c814ef4 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Fri, 3 May 2024 16:21:42 +0000 Subject: [PATCH] Move to new organization. --- .github/workflows/Tools.java | 162 ++++++++++++++++++ .github/workflows/deploy-release.sh | 58 +++++++ .github/workflows/deploy-snapshot.sh | 44 +++++ .../workflows/deploy.linux.temurin.lts.yml | 28 +++ .../workflows/main.linux.temurin.current.yml | 14 +- .github/workflows/main.linux.temurin.lts.yml | 25 ++- .../main.windows.temurin.current.yml | 14 +- .../workflows/main.windows.temurin.lts.yml | 14 +- README-CHANGES.xml | 2 +- README.md | 10 +- pom.xml | 10 +- src/site/resources/overview.xml | 8 +- 12 files changed, 369 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/Tools.java create mode 100755 .github/workflows/deploy-release.sh create mode 100755 .github/workflows/deploy-snapshot.sh create mode 100644 .github/workflows/deploy.linux.temurin.lts.yml diff --git a/.github/workflows/Tools.java b/.github/workflows/Tools.java new file mode 100644 index 0000000..32c63c3 --- /dev/null +++ b/.github/workflows/Tools.java @@ -0,0 +1,162 @@ +/* + * Copyright © 2024 Mark Raynsford https://www.io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathFactory; +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.TreeMap; + +public final class Tools +{ + private static final TreeMap OPS = + new TreeMap<>(); + + static { + final var opsList = List.of( + new ShowProjectVersion(), + new ShowProjectIsSnapshot() + ); + + for (final var op : opsList) { + OPS.put(op.name(), op); + } + } + + private Tools() + { + + } + + private interface OpType + { + String name(); + + void execute(String[] args) + throws Exception; + } + + private static String getProjectVersion( + final File file) + throws Exception + { + final var documentBuilders = + DocumentBuilderFactory.newInstance(); + final var documentBuilder = + documentBuilders.newDocumentBuilder(); + final var document = + documentBuilder.parse(file); + + final var xPathFactory = + XPathFactory.newInstance(); + final var xPath = + xPathFactory.newXPath(); + + final var nodes = + (NodeList) xPath.evaluate( + "//project/version", + document, + XPathConstants.NODESET + ); + + for (var i = 0; i < nodes.getLength(); i++) { + final var node = nodes.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + return node.getTextContent().trim(); + } + } + + throw new IOException( + "Could not locate a //project/version node!" + ); + } + + private static final class ShowProjectVersion implements OpType + { + ShowProjectVersion() + { + + } + + @Override + public String name() + { + return "ShowProjectVersion"; + } + + @Override + public void execute( + final String[] args) + throws Exception + { + System.out.print("IO7M_PROJECT_VERSION="); + System.out.println(getProjectVersion(new File(args[1]))); + } + } + + private static final class ShowProjectIsSnapshot implements OpType + { + ShowProjectIsSnapshot() + { + + } + + @Override + public String name() + { + return "ShowProjectIsSnapshot"; + } + + @Override + public void execute( + final String[] args) + throws Exception + { + System.out.print("IO7M_PROJECT_VERSION_IS_SNAPSHOT="); + System.out.println( + getProjectVersion(new File(args[1])).endsWith("-SNAPSHOT") + ); + } + } + + public static void main( + final String[] args) + throws Exception + { + if (args.length == 0) { + System.err.println("Usage: command"); + System.exit(1); + } + + final var op = OPS.get(args[0]); + if (op == null) { + System.err.println("Unrecognized command."); + System.err.println(" Must be one of:"); + for (final var name : OPS.keySet()) { + System.err.print(" "); + System.err.println(name); + } + System.exit(1); + } + + op.execute(args); + } +} \ No newline at end of file diff --git a/.github/workflows/deploy-release.sh b/.github/workflows/deploy-release.sh new file mode 100755 index 0000000..e25fc82 --- /dev/null +++ b/.github/workflows/deploy-release.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +fatal() +{ + echo "fatal: $1" 1>&2 + exit 1 +} + +if [ -z "${MAVEN_CENTRAL_USERNAME}" ] +then + fatal "MAVEN_CENTRAL_USERNAME is not set." +fi + +if [ -z "${MAVEN_CENTRAL_PASSWORD}" ] +then + fatal "MAVEN_CENTRAL_PASSWORD is not set." +fi + +(cat < + + + + io7m + + true + github-ci-maven-rsa-key + true + + + + + + + sonatype-nexus-snapshots + ${MAVEN_CENTRAL_USERNAME} + ${MAVEN_CENTRAL_PASSWORD} + + + sonatype-nexus-staging + ${MAVEN_CENTRAL_USERNAME} + ${MAVEN_CENTRAL_PASSWORD} + + + +EOF +) > "$HOME/.m2/settings.xml" || fatal "could not update $HOME/.m2/settings.xml" + +exec mvn \ +-Dio7m.release=true \ +-Dio7m.deployment=true \ +--batch-mode \ +--strict-checksums \ +-DskipTests=true \ +-DskipITs=true deploy diff --git a/.github/workflows/deploy-snapshot.sh b/.github/workflows/deploy-snapshot.sh new file mode 100755 index 0000000..227c79c --- /dev/null +++ b/.github/workflows/deploy-snapshot.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +fatal() +{ + echo "fatal: $1" 1>&2 + exit 1 +} + +if [ -z "${MAVEN_CENTRAL_USERNAME}" ] +then + fatal "MAVEN_CENTRAL_USERNAME is not set." +fi + +if [ -z "${MAVEN_CENTRAL_PASSWORD}" ] +then + fatal "MAVEN_CENTRAL_PASSWORD is not set." +fi + +(cat < + + + sonatype-nexus-snapshots + ${MAVEN_CENTRAL_USERNAME} + ${MAVEN_CENTRAL_PASSWORD} + + + sonatype-nexus-staging + ${MAVEN_CENTRAL_USERNAME} + ${MAVEN_CENTRAL_PASSWORD} + + + +EOF +) > "$HOME/.m2/settings.xml" || fatal "could not update $HOME/.m2/settings.xml" + +exec mvn \ +--batch-mode \ +--strict-checksums \ +-DskipTests=true \ +-DskipITs=true deploy diff --git a/.github/workflows/deploy.linux.temurin.lts.yml b/.github/workflows/deploy.linux.temurin.lts.yml new file mode 100644 index 0000000..e3c880f --- /dev/null +++ b/.github/workflows/deploy.linux.temurin.lts.yml @@ -0,0 +1,28 @@ +name: deploy.linux.temurin.lts + +on: + push: + tags: [ com.io7m.usq-* ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: JDK + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: 'temurin' + + - name: Import signing key + env: + PGP_SIGNING_KEY: ${{ secrets.PGP_SIGNING_KEY }} + run: echo "${PGP_SIGNING_KEY}" | gpg --import + + - name: Deploy release + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + run: .github/workflows/deploy-release.sh diff --git a/.github/workflows/main.linux.temurin.current.yml b/.github/workflows/main.linux.temurin.current.yml index 073515a..0b2e1db 100644 --- a/.github/workflows/main.linux.temurin.current.yml +++ b/.github/workflows/main.linux.temurin.current.yml @@ -11,16 +11,28 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: JDK uses: actions/setup-java@v4 with: java-version: 22 distribution: 'temurin' + + - name: Collect project version + id: project_version + run: java .github/workflows/Tools.java ShowProjectVersion pom.xml >> "$GITHUB_OUTPUT" + + - name: Collect project snapshot + id: project_is_snapshot + run: java .github/workflows/Tools.java ShowProjectIsSnapshot pom.xml >> "$GITHUB_OUTPUT" + - name: Build - run: mvn --errors clean verify site + run: mvn --batch-mode --strict-checksums --errors clean verify site + - name: Upload test logs uses: actions/upload-artifact@v4 if: always() with: name: test-logs path: ./com.io7m.usq.tests/target/surefire-reports + diff --git a/.github/workflows/main.linux.temurin.lts.yml b/.github/workflows/main.linux.temurin.lts.yml index c924e87..6a83cab 100644 --- a/.github/workflows/main.linux.temurin.lts.yml +++ b/.github/workflows/main.linux.temurin.lts.yml @@ -11,20 +11,41 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: JDK uses: actions/setup-java@v4 with: java-version: 21 distribution: 'temurin' + + - name: Collect project version + id: project_version + run: java .github/workflows/Tools.java ShowProjectVersion pom.xml >> "$GITHUB_OUTPUT" + + - name: Collect project snapshot + id: project_is_snapshot + run: java .github/workflows/Tools.java ShowProjectIsSnapshot pom.xml >> "$GITHUB_OUTPUT" + - name: Build - run: mvn --errors clean verify site + run: mvn --batch-mode --strict-checksums --errors clean verify site + - name: Upload test logs uses: actions/upload-artifact@v4 if: always() with: name: test-logs path: ./com.io7m.usq.tests/target/surefire-reports + - name: Coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4.3.1 with: + token: ${{ secrets.CODECOV_TOKEN }} file: com.io7m.usq.tests/target/site/jacoco-aggregate/jacoco.xml + + - name: Deploy snapshot + if: ${{ steps.project_is_snapshot.outputs.IO7M_PROJECT_VERSION_IS_SNAPSHOT == 'true' }} + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + run: .github/workflows/deploy-snapshot.sh + diff --git a/.github/workflows/main.windows.temurin.current.yml b/.github/workflows/main.windows.temurin.current.yml index f02b905..373e2fb 100644 --- a/.github/workflows/main.windows.temurin.current.yml +++ b/.github/workflows/main.windows.temurin.current.yml @@ -11,16 +11,28 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v4 + - name: JDK uses: actions/setup-java@v4 with: java-version: 22 distribution: 'temurin' + + - name: Collect project version + id: project_version + run: java .github/workflows/Tools.java ShowProjectVersion pom.xml >> "$GITHUB_OUTPUT" + + - name: Collect project snapshot + id: project_is_snapshot + run: java .github/workflows/Tools.java ShowProjectIsSnapshot pom.xml >> "$GITHUB_OUTPUT" + - name: Build - run: mvn --errors clean verify site + run: mvn --batch-mode --strict-checksums --errors clean verify site + - name: Upload test logs uses: actions/upload-artifact@v4 if: always() with: name: test-logs path: ./com.io7m.usq.tests/target/surefire-reports + diff --git a/.github/workflows/main.windows.temurin.lts.yml b/.github/workflows/main.windows.temurin.lts.yml index 710a8e8..b564b66 100644 --- a/.github/workflows/main.windows.temurin.lts.yml +++ b/.github/workflows/main.windows.temurin.lts.yml @@ -11,16 +11,28 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v4 + - name: JDK uses: actions/setup-java@v4 with: java-version: 21 distribution: 'temurin' + + - name: Collect project version + id: project_version + run: java .github/workflows/Tools.java ShowProjectVersion pom.xml >> "$GITHUB_OUTPUT" + + - name: Collect project snapshot + id: project_is_snapshot + run: java .github/workflows/Tools.java ShowProjectIsSnapshot pom.xml >> "$GITHUB_OUTPUT" + - name: Build - run: mvn --errors clean verify site + run: mvn --batch-mode --strict-checksums --errors clean verify site + - name: Upload test logs uses: actions/upload-artifact@v4 if: always() with: name: test-logs path: ./com.io7m.usq.tests/target/surefire-reports + diff --git a/README-CHANGES.xml b/README-CHANGES.xml index 84216ce..a937120 100644 --- a/README-CHANGES.xml +++ b/README-CHANGES.xml @@ -2,6 +2,6 @@ - + diff --git a/README.md b/README.md index 4ef1a0d..e410168 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ usq [![Maven Central](https://img.shields.io/maven-central/v/com.io7m.usq/com.io7m.usq.svg?style=flat-square)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.io7m.usq%22) [![Maven Central (snapshot)](https://img.shields.io/nexus/s/com.io7m.usq/com.io7m.usq?server=https%3A%2F%2Fs01.oss.sonatype.org&style=flat-square)](https://s01.oss.sonatype.org/content/repositories/snapshots/com/io7m/usq/) -[![Codecov](https://img.shields.io/codecov/c/github/io7m/usq.svg?style=flat-square)](https://codecov.io/gh/io7m/usq) +[![Codecov](https://img.shields.io/codecov/c/github/io7m-com/usq.svg?style=flat-square)](https://codecov.io/gh/io7m-com/usq) ![com.io7m.usq](./src/site/resources/usq.jpg?raw=true) | JVM | Platform | Status | |-----|----------|--------| -| OpenJDK (Temurin) Current | Linux | [![Build (OpenJDK (Temurin) Current, Linux)](https://img.shields.io/github/actions/workflow/status/io7m/usq/main.linux.temurin.current.yml)](https://github.com/io7m/usq/actions?query=workflow%3Amain.linux.temurin.current)| -| OpenJDK (Temurin) LTS | Linux | [![Build (OpenJDK (Temurin) LTS, Linux)](https://img.shields.io/github/actions/workflow/status/io7m/usq/main.linux.temurin.lts.yml)](https://github.com/io7m/usq/actions?query=workflow%3Amain.linux.temurin.lts)| -| OpenJDK (Temurin) Current | Windows | [![Build (OpenJDK (Temurin) Current, Windows)](https://img.shields.io/github/actions/workflow/status/io7m/usq/main.windows.temurin.current.yml)](https://github.com/io7m/usq/actions?query=workflow%3Amain.windows.temurin.current)| -| OpenJDK (Temurin) LTS | Windows | [![Build (OpenJDK (Temurin) LTS, Windows)](https://img.shields.io/github/actions/workflow/status/io7m/usq/main.windows.temurin.lts.yml)](https://github.com/io7m/usq/actions?query=workflow%3Amain.windows.temurin.lts)| +| OpenJDK (Temurin) Current | Linux | [![Build (OpenJDK (Temurin) Current, Linux)](https://img.shields.io/github/actions/workflow/status/io7m-com/usq/main.linux.temurin.current.yml)](https://www.github.com/io7m-com/usq/actions?query=workflow%3Amain.linux.temurin.current)| +| OpenJDK (Temurin) LTS | Linux | [![Build (OpenJDK (Temurin) LTS, Linux)](https://img.shields.io/github/actions/workflow/status/io7m-com/usq/main.linux.temurin.lts.yml)](https://www.github.com/io7m-com/usq/actions?query=workflow%3Amain.linux.temurin.lts)| +| OpenJDK (Temurin) Current | Windows | [![Build (OpenJDK (Temurin) Current, Windows)](https://img.shields.io/github/actions/workflow/status/io7m-com/usq/main.windows.temurin.current.yml)](https://www.github.com/io7m-com/usq/actions?query=workflow%3Amain.windows.temurin.current)| +| OpenJDK (Temurin) LTS | Windows | [![Build (OpenJDK (Temurin) LTS, Windows)](https://img.shields.io/github/actions/workflow/status/io7m-com/usq/main.windows.temurin.lts.yml)](https://www.github.com/io7m-com/usq/actions?query=workflow%3Amain.windows.temurin.lts)| diff --git a/pom.xml b/pom.xml index 6adb0ad..74a6adc 100644 --- a/pom.xml +++ b/pom.xml @@ -48,9 +48,9 @@ - https://www.github.com/io7m/usq - scm:git:https://www.github.com/io7m/usq - scm:git:https://www.github.com/io7m/usq + https://www.github.com/io7m-com/usq + scm:git:https://www.github.com/io7m-com/usq + scm:git:https://www.github.com/io7m-com/usq 2024 @@ -65,7 +65,7 @@ - https://www.github.com/io7m/usq/issues + https://www.github.com/io7m-com/usq/issues GitHub Issues @@ -83,7 +83,7 @@ GitHub Actions - https://www.github.com/io7m/usq/actions + https://www.github.com/io7m-com/usq/actions diff --git a/src/site/resources/overview.xml b/src/site/resources/overview.xml index cf4d3fa..e98cdb4 100644 --- a/src/site/resources/overview.xml +++ b/src/site/resources/overview.xml @@ -1,15 +1,15 @@