Fix auth #5
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: Release | |
on: | |
push: | |
branches: | |
- release | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.DAPLA_BOT_APP_ID }} | |
private-key: ${{ secrets.DAPLA_BOT_PRIVATE_KEY }} | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
ref: refs/heads/main | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 21 | |
distribution: zulu | |
server-id: github | |
- name: Authenticate to Google Cloud | |
id: auth | |
uses: google-github-actions/[email protected] | |
with: | |
workload_identity_provider: "projects/848539402404/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions" | |
service_account: "gh-actions-dapla-pseudo@artifact-registry-5n.iam.gserviceaccount.com" | |
token_format: access_token | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Configure Git user | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions" | |
- uses: s4u/[email protected] | |
id: maven_settings | |
with: | |
servers: '[{"id": "github","configuration": {"httpHeaders": {"property": {"name": "Authorization","value": "Bearer ${{ secrets.GITHUB_TOKEN }}"}}}}]' | |
- name: Perform release and publish jar | |
id: release_jar | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mvn --batch-mode -P ssb-bip -DskipTests release:prepare | |
TAG=$(git describe --abbrev=0 --tags) | |
echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
mvn --batch-mode -P ssb-bip -DskipTests release:perform | |
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout) | |
echo "artifact_id=${ARTIFACT_ID}" >> $GITHUB_OUTPUT | |
ARTIFACT_PATH=$(realpath ./target/$ARTIFACT_ID*.jar) | |
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT | |
- env: | |
EVENT_CONTEXT: ${{ toJSON(github.event) }} | |
run: | | |
echo $EVENT_CONTEXT | |
- name: Create GitHub release draft | |
uses: release-drafter/release-drafter@v5 | |
id: create_github_release | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
with: | |
tag: ${{ steps.release_jar.outputs.tag }} | |
- name: Publish GitHub release | |
uses: eregon/publish-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
with: | |
release_id: ${{ steps.create_github_release.outputs.id }} | |
- name: Upload assets to GitHub release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
with: | |
asset_path: ${{ steps.release_jar.outputs.artifact_path }} | |
asset_name: ${{ steps.release_jar.outputs.artifact_id }}.jar | |
asset_content_type: application/java-archive | |
upload_url: ${{ steps.create_github_release.outputs.upload_url }} | |
- name: Publish GitHub release | |
uses: eregon/publish-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
with: | |
release_id: ${{ steps.create_github_release.outputs.id }} |