From 06900930031038715a6a3cdfd49839cb7febc2be Mon Sep 17 00:00:00 2001 From: Mikhail Puzanov Date: Tue, 3 Jan 2023 16:44:17 +0100 Subject: [PATCH 1/3] Add release action --- .github/workflows/release.yml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..244ab6d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: release + +on: + push: + branches: [ main ] + tags: 'ipresource-*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Prepare environment + run: | + sudo apt-get install rsync git gnupg + + - name: Checkout Code + uses: actions/checkout@v3.2.0 + + - name: Setup Java + uses: actions/setup-java@v1.4.3 + with: + java-version: 8 + + - name: Release + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + GPG_KEY: ${{ secrets.GPG_KEY }} + SONATYPE_NEXUS_SNAPSHOTS_USERNAME: ${{ secrets.SONATYPE_NEXUS_SNAPSHOTS_USERNAME }} + SONATYPE_NEXUS_SNAPSHOTS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_SNAPSHOTS_PASSWORD }} + SONATYPE_NEXUS_STAGING_USERNAME: ${{ secrets.SONATYPE_NEXUS_STAGING_USERNAME }} + SONATYPE_NEXUS_STAGING_PASSWORD: ${{ secrets.SONATYPE_NEXUS_STAGING_PASSWORD }} + run: | + # checking GPG signing support + if [ -n "$GPG_KEY" ]; then + echo "$GPG_KEY" | gpg --batch --no-tty --allow-secret-key-import --import - + unset GPG_KEY + export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5) + + # GPG stuff works, do the release + export MAVEN_OPTS="-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$HOME/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" + + VERSION=$(echo ${GITHUB_REF#refs/*/} | sed -e 's/ipresource-//') + echo "Will be releasing ${VERSION}" + + mvn versions:set -DnewVersion=${VERSION} + mvn $MAVEN_CLI_OPTS deploy -s ci_settings.xml -P default,release + echo "done" + else + echo -e "\033[0;31m****** GPG signing disabled ******\033[0m" + fi + \ No newline at end of file From cca3f59e2483522b22101562721d372797388fb3 Mon Sep 17 00:00:00 2001 From: Mikhail Puzanov Date: Tue, 3 Jan 2023 16:44:33 +0100 Subject: [PATCH 2/3] Don't push to git --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 3a3e131..67d2d37 100644 --- a/pom.xml +++ b/pom.xml @@ -282,6 +282,9 @@ org.apache.maven.plugins maven-release-plugin 2.5.3 + + false + From 0ce6597ed27c8c23efa1f8f42bd54ae69b5d134a Mon Sep 17 00:00:00 2001 From: Mikhail Puzanov Date: Mon, 9 Jan 2023 13:39:07 +0100 Subject: [PATCH 3/3] Check for repository --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 244ab6d..c26f7da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,8 +7,8 @@ on: jobs: build: + if: github.repository == 'RIPE-NCC/ipresource' runs-on: ubuntu-latest - steps: - name: Prepare environment run: |