Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit fd9e42b

Browse files
authored
Create release.yml
1 parent 77047a3 commit fd9e42b

File tree

1 file changed

+202
-0
lines changed

1 file changed

+202
-0
lines changed

.github/workflows/release.yml

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
check_code: # Validates the code (see develop.yml)
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Set up JDK 8
14+
uses: actions/setup-java@v2
15+
with:
16+
distribution: 'temurin'
17+
java-version: '8'
18+
cache: 'maven'
19+
20+
- name: Build with Maven
21+
run: mvn -B clean verify
22+
23+
- name: Check for uncommited changes
24+
run: |
25+
if [[ "$(git status --porcelain)" != "" ]]; then
26+
echo ----------------------------------------
27+
echo git status
28+
echo ----------------------------------------
29+
git status
30+
echo ----------------------------------------
31+
echo git diff
32+
echo ----------------------------------------
33+
git diff
34+
echo ----------------------------------------
35+
echo Troubleshooting
36+
echo ----------------------------------------
37+
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean verify"
38+
exit 1
39+
fi
40+
41+
prepare_release:
42+
runs-on: ubuntu-latest
43+
needs: [check_code]
44+
outputs:
45+
upload_url: ${{ steps.create_draft.outputs.upload_url }}
46+
steps:
47+
- uses: actions/checkout@v2
48+
49+
- name: Configure Git
50+
run: |
51+
git config --global user.email "actions@github.com"
52+
git config --global user.name "GitHub Actions"
53+
54+
- name: Un-SNAP
55+
run: mvn -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false
56+
57+
- name: Get version
58+
id: version
59+
run: |
60+
echo "::set-output name=release::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
61+
62+
- name: Commit and Push
63+
run: |
64+
git add -A
65+
git commit -m "Release ${{ steps.version.outputs.release }}"
66+
git push origin
67+
git tag v${{ steps.version.outputs.release }}
68+
git push origin --tags
69+
70+
- name: Create Release
71+
id: create_release
72+
uses: actions/create-release@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
with:
76+
tag_name: v${{ steps.version.outputs.release }}
77+
release_name: v${{ steps.version.outputs.release }}
78+
commitish: master
79+
body: |
80+
## Installation [![Maven Central](https://img.shields.io/maven-central/v/com.xdev-software/xapi-db-mssql-2012?versionPrefix=${{ steps.version.outputs.release }})](https://mvnrepository.com/artifact/com.xdev-software/xapi-db-mssql-2012)
81+
Add the following lines to your pom:
82+
```XML
83+
<dependency>
84+
<groupId>com.xdev-software</groupId>
85+
<artifactId>xapi-db-mssql-2012</artifactId>
86+
<version>${{ steps.version.outputs.release }}</version>
87+
</dependency>
88+
```
89+
draft: false
90+
prerelease: false
91+
92+
publish_central: # Publish the code to central
93+
runs-on: ubuntu-latest
94+
needs: [prepare_release]
95+
steps:
96+
- uses: actions/checkout@v2
97+
98+
- name: Init Git and pull
99+
run: |
100+
git config --global user.email "actions@github.com"
101+
git config --global user.name "GitHub Actions"
102+
git pull
103+
104+
- name: Set up JDK 8 OSSRH
105+
uses: actions/setup-java@v2
106+
with: # running setup-java again overwrites the settings.xml
107+
distribution: 'temurin'
108+
java-version: '8'
109+
server-id: ossrh
110+
server-username: MAVEN_CENTRAL_USERNAME
111+
server-password: MAVEN_CENTRAL_TOKEN
112+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
113+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
114+
115+
- name: Publish to OSSRH
116+
run: mvn -B deploy -Possrh
117+
env:
118+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
119+
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
120+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
121+
122+
publish-pages:
123+
name: Publish dependencies and licenses to github pages
124+
runs-on: ubuntu-latest
125+
needs: [prepare_release]
126+
steps:
127+
- uses: actions/checkout@v2
128+
129+
- name: Init Git and pull
130+
run: |
131+
git config --global user.email "actions@github.com"
132+
git config --global user.name "GitHub Actions"
133+
git pull
134+
135+
- name: Set up JDK 8
136+
uses: actions/setup-java@v2
137+
with:
138+
distribution: 'temurin'
139+
java-version: '8'
140+
141+
- name: Build dependencies/licenses files
142+
run: mvn -B project-info-reports:dependencies
143+
144+
- name: Upload licenses - Upload Artifact
145+
uses: actions/upload-artifact@v2
146+
with:
147+
name: dependencies-licenses
148+
path: target/site
149+
150+
- name: Generate docs/dependencies dir
151+
run: mkdir -p docs/dependencies
152+
153+
- name: Move built files into docs/dependencies
154+
run: mv target/site/* docs/dependencies
155+
156+
- name: Rename dependencies.html to index.html
157+
working-directory: docs/dependencies
158+
run: mv dependencies.html index.html
159+
160+
- name: Copy Readme into docs (as index.md)
161+
run: cp README.md docs/index.md
162+
163+
- name: Configure Pages
164+
working-directory: docs
165+
run: |-
166+
echo "theme: jekyll-theme-tactile" > _config.yml
167+
168+
- name: Deploy to Github pages
169+
uses: peaceiris/actions-gh-pages@v3
170+
with:
171+
github_token: ${{ secrets.GITHUB_TOKEN }}
172+
publish_dir: ./docs
173+
enable_jekyll: true
174+
175+
after_release:
176+
runs-on: ubuntu-latest
177+
needs: [publish_central]
178+
steps:
179+
- uses: actions/checkout@v2
180+
181+
- name: Init Git and pull
182+
run: |
183+
git config --global user.email "actions@github.com"
184+
git config --global user.name "GitHub Actions"
185+
git pull
186+
187+
- name: Inc Version and SNAP root
188+
run: mvn -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true
189+
190+
- name: Git Commit and Push
191+
run: |
192+
git add -A
193+
git commit -m "Preparing for next development iteration"
194+
git push origin
195+
196+
- name: pull-request
197+
uses: repo-sync/pull-request@v2
198+
with:
199+
github_token: ${{ secrets.GITHUB_TOKEN }}
200+
destination_branch: "develop"
201+
pr_title: "Sync back"
202+
pr_body: "An automated PR to sync changes back"

0 commit comments

Comments
 (0)