Skip to content

Commit

Permalink
Add a github workflow for pre-releases
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis committed Jan 7, 2025
1 parent 63d0574 commit 767b079
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-test[0-9]+'
jobs:
publish-pre-release:
name: Publish pre-release
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
server-username: NEXUS_USER
server-password: NEXUS_PW
gpg-private-key: ${{ secrets.BAREMAPS_GPG_SECRET_KEY }}

- name: Extract variables
id: variables
run: |
echo "git_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "git_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "mvn_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
- name: Build pre-release
run: mvn install -DskipTests -Dmaven.javadoc.skip=true -B -V

- name: Set up GPG
run: |
echo "${{ secrets.BAREMAPS_GPG_SECRET_KEY }}" | gpg --batch --import
gpg --list-keys
env:
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}

- name: Sign and hash pre-release
run: |
cd ./baremaps-cli/target
mv apache-baremaps-${{ steps.variables.outputs.mvn_version }}-incubating-src.tar.gz apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz
shasum -a 512 "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz" > "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz.sha512"
gpg --no-tty --quiet --pinentry-mode loopback --default-key "${{ secrets.GPG_KEY_ID }}" --batch --yes --output "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz.asc" --detach-sign --armor "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz"
mv apache-baremaps-${{ steps.variables.outputs.mvn_version }}-incubating-bin.tar.gz apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz
shasum -a 512 "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz" > "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz.sha512"
gpg --no-tty --quiet --pinentry-mode loopback --default-key "${{ secrets.GPG_KEY_ID }}" --batch --yes --output "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz.asc" --detach-sign --armor "./apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz"
cd -
- name: Publish pre-release on GitHub
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.variables.outputs.git_tag }}" --draft --prerelease --title "Apache Baremaps ${{ steps.variables.outputs.git_version }} (incubating)" --repo ${{ github.repository }} --generate-notes
gh release upload --clobber "${{ steps.variables.outputs.git_tag }}" ./baremaps-cli/target/apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz
gh release upload --clobber "${{ steps.variables.outputs.git_tag }}" ./baremaps-cli/target/apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz.sha512
gh release upload --clobber "${{ steps.variables.outputs.git_tag }}" ./baremaps-cli/target/apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz.asc
gh release upload --clobber "${{ steps.variables.outputs.git_tag }}" ./baremaps-cli/target/apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz
gh release upload --clobber "${{ steps.variables.outputs.git_tag }}" ./baremaps-cli/target/apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz.sha512
gh release upload --clobber "${{ steps.variables.outputs.git_tag }}" ./baremaps-cli/target/apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-bin.tar.gz.asc
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'

jobs:
publish-candidate:
name: Publish candidate
runs-on: ubuntu-latest
Expand All @@ -31,7 +30,7 @@ jobs:
echo "git_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "mvn_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
- name: Build candidate
- name: Build release candidate
run: mvn install -DskipTests -Dmaven.javadoc.skip=true -B -V

- name: Set up GPG
Expand All @@ -41,7 +40,7 @@ jobs:
env:
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}

- name: Sign and hash candidate
- name: Sign and hash release candidate
run: |
cd ./baremaps-cli/target
mv apache-baremaps-${{ steps.variables.outputs.mvn_version }}-incubating-src.tar.gz apache-baremaps-${{ steps.variables.outputs.git_version }}-incubating-src.tar.gz
Expand Down

0 comments on commit 767b079

Please sign in to comment.