Build and tag-based release #31
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: Build and tag-based release | |
on: | |
push: | |
branches: [ "main" ] | |
create: | |
tags: | |
- '*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 11 | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B -f pom_for_bundle.xml -PbuildKar clean package -Dmaven.test.skip=true | |
- name: Determine Artifact Path | |
run: echo "ARTIFACT_PATH=$(ls target/nexus-oauth2-proxy-plugin-*-bundle.kar)" >> $GITHUB_ENV | |
- name: Upload Artifact to Workflow | |
uses: actions/upload-artifact@v3 | |
with: | |
name: nexus-oauth2-proxy-plugin-java-11.kar | |
path: ${{ env.ARTIFACT_PATH }} | |
prepare_release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/') | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Extract tag name | |
run: | | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
RELEASE_NAME="Release $TAG_NAME" | |
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: ${{ env.RELEASE_NAME }} | |
draft: false | |
prerelease: false | |
upload_release_asset: | |
needs: [prepare_release] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: nexus-oauth2-proxy-plugin-java-11.kar | |
- name: Find KAR file | |
id: find_kar | |
run: | | |
kar_path=$(find . -name "*.kar") | |
kar_name=$(basename "$kar_path") | |
echo "KAR_PATH=$kar_path" >> $GITHUB_ENV | |
echo "kar_name=$kar_name" >> $GITHUB_ENV | |
echo "kar_name=$kar_name" >> $GITHUB_OUTPUT | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.prepare_release.outputs.upload_url }} | |
asset_path: ${{ env.KAR_PATH }} | |
asset_name: ${{ env.kar_name }} | |
asset_content_type: application/zip |