Skip to content

Create a new release #39

Create a new release

Create a new release #39

# This is a basic workflow to help you get started with Actions
name: Create a new release
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
releaseTitle:
description: "Title for the release"
required: false
default: ""
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.ACHIYAPAT }}
- name: Extract next version
run: |
echo "VER_MINOR=$((`sed -nE 's|<version>[0-9]+\.[0-9]+\.([0-9]*)<.*|\1|p' pom.xml | head -n 1` + 1))" >> $GITHUB_ENV
VER_MINOR=$((`sed -nE 's|<version>[0-9]+\.[0-9]+\.([0-9]*)<.*|\1|p' pom.xml | head -n 1` + 1))
echo "VER_MAJOR=`sed -nE 's|[ \t]*<version>([0-9]+\.[0-9]+\.)[0-9]*<.*|\1|p' pom.xml | head -n 1`" >> $GITHUB_ENV
VER_MAJOR=`sed -nE 's|[ \t]*<version>([0-9]+\.[0-9]+\.)[0-9]*<.*|\1|p' pom.xml | head -n 1`
echo "VER=${VER_MAJOR}${VER_MINOR}" >> $GITHUB_ENV
- name: Raise POM and README.md version
run: |
echo "VER==${{ env.VER }} === VER_MAJOR==${{ env.VER_MAJOR }} === VER_MINOR==${{ env.VER_MINOR }}"
perl -pi -e '$a=1 if(!$a && s|(<version>[0-9]+\.[0-9]+\.)[0-9]*|${1}${{ env.VER_MINOR }}|);' pom.xml
perl -pi -e '$a=1 if(!$a && s|(<version>[0-9]+\.[0-9]+\.)[0-9]*|${1}${{ env.VER_MINOR }}|);' README.md
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "raise version"
git push
- name: Set SHA version
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse HEAD)"
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VER }}
release_name: Release ${{ env.VER }}
draft: false
prerelease: false
commitish: ${{ steps.vars.outputs.sha_short }}
# From here: create uber-jar and upload as an asset to the release.
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Maven
run: |
mvn package -P"uber-jar"
ls -al
ls -al target/
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./target/BPjs-Context-${{ env.VER }}.uber.jar
asset_name: BPjs-Context-${{ env.VER }}.uber.jar
asset_content_type: application/java-archive