-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (113 loc) · 5.18 KB
/
continuous-delivery.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Continuous Delivery
on:
push:
branches:
- maintenance-1
paths-ignore:
# - '.github/**'
- '**/README.md'
env:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
FTA_TAG_PREFIX: 'maintenance-1-v'
steps:
- uses: actions/checkout@v4
- name: Bump version and create tag
id: semanticversion
uses: mathieudutour/github-tag-action@v6.2
with:
release_branches: maintenance-1
github_token: ${{ secrets.GITHUB_TOKEN }}
fetch_all_tags: true
tag_prefix: ${{ env.FTA_TAG_PREFIX }}
- name: Verify and print new build number
run: |
if echo '${{ steps.semanticversion.outputs.new_tag }}' |grep -Eq '^${{ env.FTA_TAG_PREFIX }}1[.][0-9]+[.][0-9]+$'; then
echo Tag '${{ steps.semanticversion.outputs.new_tag }}', New version '${{ steps.semanticversion.outputs.new_version }}', Changelog '${{ steps.semanticversion.outputs.changelog }}'
else
echo 'unexpected tag format - aborting'
exit -1
fi
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
## Build with maven
- name: Prepare maven settings
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p ~/.m2
echo "<settings><servers><server><id>github</id><username>x-access-token</username><password>${GITHUB_TOKEN}</password></server></servers></settings>" > ~/.m2/settings.xml
- name: Set version
id: version
run: |
echo Releasing as ${{ steps.semanticversion.outputs.new_version }}
mvn $MAVEN_CLI_OPTS versions:set -DnewVersion=${{ steps.semanticversion.outputs.new_version }}
- name: Perform build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: mvn $MAVEN_CLI_OPTS package
## Deploy
- name: Deploy package
env:
GPG_EXECUTABLE: gpg
GPG_SECRET_KEYS: ${{ secrets.LEVIGO_GPG_KEYS }}
GPG_OWNERTRUST: ${{ secrets.LEVIGO_GPG_OWNERTRUST }}
GPG_PASSPHRASE: ${{ secrets.LEVIGO_GPG_PASSPHRASE }}
SONATYPE_USERNAME: ${{ secrets.LEVIGO_SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.LEVIGO_SONATYPE_PASSWORD }}
run: |
echo "$GPG_SECRET_KEYS" | base64 --decode | $GPG_EXECUTABLE --import --no-tty --batch --yes
echo "$GPG_OWNERTRUST" | base64 --decode | $GPG_EXECUTABLE --import-ownertrust --no-tty --batch --yes
mvn $MAVEN_CLI_OPTS deploy --settings .maven.xml -Dmaven.test.skip.exec=true -U -Prelease
## Update README.md
- name: Edit README.md to contain version number
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout maintenance-1
git reset --hard HEAD
sed -ri "s,<version>.*</version>,<version>${{ steps.semanticversion.outputs.new_version }}</version>," README.md
# cut everything after 'Recognized formats' from the README.md
head -n $(( $(grep -n 'Recognized formats' README.md | cut -d ':' -f 1) + 1 )) README.md > README.md.new
mv README.md.new README.md
# extract list of mime-types from magic.xml and append to README.md
grep -Po '(?<=<mime-type>)[^<]+' src/main/resources/magic.xml | sort | uniq | xargs printf "\t%s\n" >> README.md
git add README.md
git commit -m "Edit README.md to contain correct version"
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: maintenance-1
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.semanticversion.outputs.new_tag }}
name: ${{ steps.semanticversion.outputs.new_version }}
## Notify Mattermost
- name: Notify Developers
uses: 8398a7/action-slack@v3
with:
username: GitHub
icon_emoji: octocat
channel: ci_js
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref
text: Released new version `${{ steps.semanticversion.outputs.new_version }}` of *${{ github.repository }}* to maven central
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: ${{ failure() && github.actor != 'dependabot[bot]' }}