Fix GitHub auth for release workflow #44
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish package to the Maven Central Repository | |
on: | |
push: | |
branches: | |
- main | |
- 22-release-the-new-version-of-the-sdjwt-library-to-maven-repository | |
permissions: | |
contents: write | |
actions: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cache Maven dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Build with Maven | |
run: mvn clean install -Dgpg.skip=true | |
release: | |
runs-on: ubuntu-latest | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} | |
GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }} | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
GIT_USER_NAME: ${{ vars.GIT_USER_NAME }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
server-id: sonatype | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
- name: Set up Git for authentication | |
run: | | |
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/" | |
- name: Set up GPG for signing | |
run: | | |
echo "$GPG_SECRET_KEY" | gpg --batch --import | |
echo "use-agent" >> ~/.gnupg/gpg.conf | |
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf | |
- name: Set up Git user for release commit | |
run: | | |
git config --global user.name "$GIT_USER_NAME" | |
git config --global user.email "$GIT_USER_EMAIL" | |
- name: Build, sign, and release | |
run: mvn clean release:prepare release:perform -Dgpg.passphrase="$GPG_PASSPHRASE" | |
env: | |
GITHUB_TOKEN: ${GITHUB_TOKEN} |