-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (75 loc) · 3.45 KB
/
create-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# 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 github-actions@github.com
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