Skip to content

Commit bdfa58a

Browse files
authored
Merge pull request #33 from secure-software-engineering/action-updates
Action Updates
2 parents 79f41f5 + 4331d52 commit bdfa58a

File tree

4 files changed

+112
-47
lines changed

4 files changed

+112
-47
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,19 @@ jobs:
88
name: PathExpression deployment
99
steps:
1010
- name: Checkout source code
11-
uses: actions/checkout@v3
11+
uses: actions/checkout@v4
1212
# Sets up Java version
1313
- name: Set up Java
14-
uses: actions/setup-java@v3
14+
uses: actions/setup-java@v4
1515
with:
1616
distribution: 'adopt'
1717
java-package: 'jdk'
18-
java-version: '11'
18+
java-version: '8'
1919
server-id: 'ossrh' # must match the serverId configured for the nexus-staging-maven-plugin
2020
server-username: OSSRH_USERNAME # Env var that holds your OSSRH user name
2121
server-password: OSSRH_PASSWORD # Env var that holds your OSSRH user pw
2222
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Substituted with the value stored in the referenced secret
2323
gpg-passphrase: SIGN_KEY_PASS # Env var that holds the key's passphrase
24-
# Sets up Maven version
25-
- name: Set up Maven
26-
uses: stCarolas/setup-maven@v4.5
27-
with:
28-
maven-version: 3.6.3
2924
- name: Build & Deploy PathExpression
3025
run: mvn -B -U clean deploy -Pdeployment
3126
env:

.github/workflows/maven.yml

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,12 @@ jobs:
88
BuildAndTest:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
- name: Set up JDK 1.8
13-
uses: actions/setup-java@v1
13+
uses: actions/setup-java@v4
1414
with:
15-
java-version: 1.8
15+
distribution: 'adopt'
16+
java-package: jdk
17+
java-version: '8'
1618
- name: Build with Maven
1719
run: mvn -B verify --file pom.xml
18-
19-
Release:
20-
name: Release
21-
if: github.ref == 'refs/heads/master'
22-
runs-on: ubuntu-latest
23-
permissions:
24-
contents: read
25-
packages: write
26-
needs: [BuildAndTest]
27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@v2
30-
- name: Set up JDK 1.8
31-
uses: actions/setup-java@v1
32-
with:
33-
java-version: 1.8
34-
- name: Release
35-
uses: qcastel/github-actions-maven-release@master
36-
env:
37-
JAVA_HOME: /usr/lib/jvm/java-1.8-openjdk/
38-
with:
39-
release-branch-name: "master"
40-
41-
gpg-enabled: "true"
42-
gpg-key-id: ${{ secrets.GPG_KEY_ID }}
43-
gpg-key: ${{ secrets.GPG_KEY }}
44-
45-
maven-repo-server-id: github
46-
maven-repo-server-username: ${{ secrets.CI_USER }}
47-
maven-repo-server-password: ${{ secrets.CI_PACKAGES_TOKEN }}
48-
49-
git-release-bot-name: ${{ secrets.CI_USER }}
50-
git-release-bot-email: "admin@codeshield.de"
51-
52-
access-token: ${{ secrets.GITHUB_TOKEN }}
53-
maven-args: "-DskipTests"

.github/workflows/version.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Version handling
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- master
9+
10+
jobs:
11+
version-update:
12+
# This version does not run on self-opened PRs
13+
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.user.login != 'github-actions[bot]' }}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout source code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
# Sets up Java version
21+
- name: Set up Java
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: 'adopt'
25+
java-package: jdk
26+
java-version: '8'
27+
# Semantic versioning
28+
- name: Semantic versioning
29+
id: versioning
30+
uses: paulhatch/semantic-version@v5.4.0
31+
with:
32+
tag_prefix: ""
33+
# A string which, if present in a git commit, indicates that a change represents a
34+
# major (breaking) change, supports regular expressions wrapped with '/'
35+
major_pattern: "(MAJOR)"
36+
# Same as above except indicating a minor change, supports regular expressions wrapped with '/'
37+
minor_pattern: "(MINOR)"
38+
# A string to determine the format of the version output
39+
version_format: "${major}.${minor}.${patch}"
40+
# Check, whether there is an existing branch "version_<version>" or an open PR "version_<version>" -> "master"
41+
# and store the results as environment variables
42+
- name: Check if branch and PR exist
43+
# The second command was copied from https://stackoverflow.com/questions/73812503/github-action-stop-the-action-if-pr-already-exists
44+
run: |
45+
echo VERSION_BRANCH_EXISTS=$(git ls-remote --heads origin refs/heads/version_${{ steps.versioning.outputs.version }} | wc -l) >> $GITHUB_ENV
46+
echo PR_EXISTS=$(gh pr list \
47+
--repo "$GITHUB_REPOSITORY" \
48+
--json baseRefName,headRefName \
49+
--jq '
50+
map(select(.baseRefName == "master" and .headRefName == "version_${{ steps.versioning.outputs.version }}"))
51+
| length
52+
') >> $GITHUB_ENV
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
# If the branch "version_<version>" does not exist, create the branch and update the version in all files
56+
- name: Create branch and update PathExpression version
57+
if: ${{ env.VERSION_BRANCH_EXISTS == '0' }}
58+
run: |
59+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
60+
git config --global user.name "github-actions[bot]"
61+
git checkout -b version_${{ steps.versioning.outputs.version }}
62+
mvn build-helper:parse-version versions:set -DnewVersion=\${{ steps.versioning.outputs.version }} versions:commit
63+
git ls-files | grep 'pom.xml$' | xargs git add
64+
git commit --allow-empty -am "Update PathExpression version to ${{ steps.versioning.outputs.version }}"
65+
git push origin version_${{ steps.versioning.outputs.version }}
66+
# If a PR "version_<version>" -> "master" does not exist, create the PR
67+
- name: Open pull request for version update
68+
if: ${{ env.PR_EXISTS == '0' }}
69+
run: |
70+
gh pr create -B master -H version_${{ steps.versioning.outputs.version }} -t "Update PathExpression version to ${{ steps.versioning.outputs.version }}" -b "This PR was created by the version-update workflow. Please make sure to delete the branch after merging, otherwise future workflows might fail."
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
version-release:
75+
# This job runs only on merged PRs, which were opened by the version-update job
76+
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.user.login == 'github-actions[bot]' }}
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout source code
80+
uses: actions/checkout@v4
81+
with:
82+
fetch-depth: 0
83+
# Semantic versioning
84+
- name: Semantic versioning
85+
id: versioning
86+
uses: paulhatch/semantic-version@v5.4.0
87+
with:
88+
tag_prefix: ""
89+
# A string which, if present in a git commit, indicates that a change represents a
90+
# major (breaking) change, supports regular expressions wrapped with '/'
91+
major_pattern: "(MAJOR)"
92+
# Same as above except indicating a minor change, supports regular expressions wrapped with '/'
93+
minor_pattern: "(MINOR)"
94+
# A string to determine the format of the version output
95+
version_format: "${major}.${minor}.${patch}"
96+
# Create a tag with the newest version to prepare a release
97+
- name: Create tag for new version
98+
run: |
99+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
100+
git config --global user.name "${{ github.actor }}"
101+
git tag -a ${{ steps.versioning.outputs.version }} -m "PathExpression version ${{ steps.versioning.outputs.version }}"
102+
git push origin ${{ steps.versioning.outputs.version }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ local.properties
101101
.settings/
102102
.loadpath
103103
.recommenders
104+
.project
105+
.classpath
104106

105107
# External tool builders
106108
.externalToolBuilders/

0 commit comments

Comments
 (0)