Skip to content

Commit 070c92f

Browse files
committed
Revert "Site checkin for project github-client"
This reverts commit 042dcef.
1 parent 042dcef commit 070c92f

File tree

1,387 files changed

+33214
-455342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,387 files changed

+33214
-455342
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/python3
2+
import re
3+
import subprocess
4+
import sys
5+
6+
7+
def get_arg(arg_idx) -> str:
8+
return sys.argv[arg_idx]
9+
10+
11+
def get_current_version() -> str:
12+
current_version_cmd = subprocess.run(
13+
"mvn help:evaluate -Dexpression=project.version -q -DforceStdout",
14+
shell=True, capture_output=True, text=True)
15+
return current_version_cmd.stdout
16+
17+
18+
def get_release_version(release_type: str, current_version: str) -> str:
19+
major, minor, patch = determine_new_version(current_version, release_type)
20+
return str(major) + "." + str(minor) + "." + str(patch)
21+
22+
23+
def get_snapshot_version(release_type: str, current_version: str) -> str:
24+
major, minor, patch = determine_new_version(current_version, release_type)
25+
patch += 1
26+
return str(major) + "." + str(minor) + "." + str(patch) + "-SNAPSHOT"
27+
28+
29+
def get_version_tag(release_type: str, current_version: str) -> str:
30+
major, minor, patch = determine_new_version(current_version, release_type)
31+
return "v" + str(major) + "." + str(minor) + "." + str(patch)
32+
33+
34+
def determine_new_version(current_version, release_type):
35+
major, minor, patch, is_prerelease = dissect_version(current_version)
36+
37+
match release_type:
38+
case "MAJOR":
39+
major, minor, patch = get_major_release_version(major)
40+
case "MINOR":
41+
major, minor, patch = get_minor_release_version(major, minor)
42+
case "PATCH":
43+
major, minor, patch = get_patch_release_version(major, minor, patch,
44+
is_prerelease)
45+
case _:
46+
print("Second arg has to be `MAJOR`, `MINOR` or `PATCH`")
47+
sys.exit()
48+
49+
return major, minor, patch
50+
51+
52+
def dissect_version(current_version) -> (int, int, int):
53+
version_regex = get_regex()
54+
regex_match = version_regex.search(current_version)
55+
major: int = int(regex_match.groupdict().get("major"))
56+
minor: int = int(regex_match.groupdict().get("minor"))
57+
patch: int = int(regex_match.groupdict().get("patch"))
58+
is_prerelease: bool = True if regex_match.groupdict().get(
59+
"prerelease") else False
60+
return major, minor, patch, is_prerelease
61+
62+
63+
def get_regex():
64+
# Following REGEX is suggested on semver.org
65+
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
66+
return re.compile(
67+
r'^'
68+
r'(?P<major>0|[1-9]\d*)'
69+
r'\.'
70+
r'(?P<minor>0|[1-9]\d*)'
71+
r'\.'
72+
r'(?P<patch>0|[1-9]\d*)'
73+
r'(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?'
74+
r'(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$')
75+
76+
77+
def get_major_release_version(major):
78+
major += 1
79+
minor = 0
80+
patch = 0
81+
return major, minor, patch
82+
83+
84+
def get_minor_release_version(major, minor):
85+
minor += 1
86+
patch = 0
87+
return major, minor, patch
88+
89+
90+
def get_patch_release_version(major, minor, patch, is_prerelease):
91+
if is_prerelease:
92+
# Leave values as is because current version without `prerelease` is new patch version
93+
return major, minor, patch
94+
return major, minor, patch + 1
95+
96+
97+
if __name__ == "__main__":
98+
99+
version_type = get_arg(1)
100+
release_type = get_arg(2)
101+
102+
current_version = get_current_version()
103+
104+
match version_type:
105+
case "release-version":
106+
new_version = get_release_version(release_type, current_version)
107+
case "version-tag":
108+
new_version = get_version_tag(release_type, current_version)
109+
case "snapshot-version":
110+
new_version = get_snapshot_version(release_type, current_version)
111+
case _:
112+
print(
113+
"First arg has to be `release-version`, `version-tag` or `snapshot-version`.")
114+
sys.exit()
115+
116+
print(new_version)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: prepare-release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release:
7+
description: Type of release
8+
required: true
9+
type: choice
10+
options:
11+
- PATCH
12+
- MINOR
13+
- MAJOR
14+
default: PATCH
15+
16+
jobs:
17+
prepare:
18+
runs-on: ubuntu-latest
19+
steps:
20+
21+
- uses: actions/checkout@v4
22+
23+
# SSH connection with keys is necessary to allow `git push`
24+
- name: Ensure correct SSH connection
25+
uses: webfactory/[email protected]
26+
with:
27+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
28+
29+
- uses: actions/setup-java@v3
30+
with:
31+
java-version: 11
32+
distribution: corretto
33+
cache: maven
34+
35+
- name: Determine new versions
36+
run: |
37+
echo "release_version=$(./.github/workflows/maven-version-determiner.py release-version $release_type)" >> "$GITHUB_ENV"
38+
echo "snapshot_version=$(./.github/workflows/maven-version-determiner.py snapshot-version $release_type)" >> "$GITHUB_ENV"
39+
echo "version_tag=$(./.github/workflows/maven-version-determiner.py version-tag $release_type)" >> "$GITHUB_ENV"
40+
env:
41+
release_type: ${{ inputs.release }}
42+
43+
- name: Configure Git user
44+
run: |
45+
git config user.email "[email protected]"
46+
git config user.name "GitHub Actions"
47+
48+
- name: Prepare with Maven release plugin
49+
run: >
50+
mvn
51+
--batch-mode
52+
-Dresume=false
53+
-Drelease-version=$release_version
54+
-Dtag=$version_tag
55+
-DdevelopmentVersion=$snapshot_version
56+
release:prepare

.github/workflows/pullrequest.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: maven-build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
# Do not execute only for specific paths if workflow is required.
8+
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
9+
10+
jobs:
11+
build:
12+
13+
strategy:
14+
matrix:
15+
os:
16+
- ubuntu-latest
17+
java-version:
18+
- 11
19+
- 17
20+
- 21
21+
22+
runs-on: ${{ matrix.os }}
23+
24+
steps:
25+
26+
- uses: actions/checkout@v4
27+
28+
- uses: actions/setup-java@v3
29+
with:
30+
java-version: ${{ matrix.java-version }}
31+
distribution: corretto
32+
cache: maven
33+
34+
- name: Build with Maven
35+
run: >
36+
mvn
37+
--batch-mode
38+
--file pom.xml
39+
-Pcoverage
40+
-Dsytle.colors=always
41+
--errors
42+
package
43+
44+
- name: Upload coverage to Codecov
45+
uses: codecov/codecov-action@v3
46+
with:
47+
token: ${{ secrets.CODECOV_TOKEN }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: github-release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: Create GitHub release of following tag
8+
required: true
9+
type: string
10+
workflow_call:
11+
inputs:
12+
tag:
13+
required: true
14+
type: string
15+
16+
jobs:
17+
create-release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
21+
- name: Create GitHub release
22+
run: |
23+
curl -L \
24+
-X POST \
25+
-H "Accept: application/vnd.github+json" \
26+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
27+
-H "X-GitHub-Api-Version: 2022-11-28" \
28+
https://api.github.com/repos/spotify/github-java-client/releases \
29+
-d '{"tag_name":"${{ inputs.tag }}","target_commitish":"master","draft":false,"prerelease":false,"generate_release_notes":true}'

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: maven-release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- '*.md'
9+
- '.gitignore'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-java@v4
19+
with:
20+
java-version: 11
21+
distribution: corretto
22+
cache: maven
23+
server-id: ossrh # Value of distributionManagement.repository.id field of pom.xml
24+
server-username: MAVEN_USERNAME
25+
server-password: MAVEN_PASSWORD
26+
settings-path: ${{ github.workspace }} # Location for settings.xml file
27+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY_ABHI }}
28+
gpg-passphrase: GPG_PASSPHRASE
29+
30+
- name: Publish with Maven deploy
31+
run: |
32+
if [ "${{ env.ACTIONS_STEP_DEBUG }}" == "true" ]; then
33+
mvn --batch-mode --activate-profiles deploy --settings $GITHUB_WORKSPACE/settings.xml -Pcoverage clean deploy -X
34+
else
35+
mvn --batch-mode --activate-profiles deploy --settings $GITHUB_WORKSPACE/settings.xml -Pcoverage clean deploy
36+
fi
37+
env:
38+
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
39+
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
40+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE_ABHI }}
41+
42+
- name: Upload coverage to Codecov
43+
uses: codecov/codecov-action@v3
44+
with:
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
47+
48+
get-tag-of-current-sha:
49+
needs: build
50+
runs-on: ubuntu-latest
51+
outputs:
52+
tag: ${{ steps.tag-retriever.outputs.tag }}
53+
# Var is empty if command to retrieve tag fails (e.g. if current SHA has no tag associated)
54+
steps:
55+
56+
- name: Clone repo with complete history and tags
57+
uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
60+
61+
- name: Store tag of SHA if present
62+
id: tag-retriever
63+
run: |
64+
echo "tag=$(git describe --exact-match ${{ github.sha }})" >> "$GITHUB_OUTPUT"
65+
66+
67+
trigger-github-release:
68+
needs: get-tag-of-current-sha
69+
name: Trigger GitHub release workflow
70+
if: needs.get-tag-of-current-sha.outputs.tag
71+
# Runs job only if tag is present.
72+
uses: ./.github/workflows/release-on-github.yml
73+
with:
74+
tag: ${{ needs.get-tag-of-current-sha.outputs.tag }}

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Artifacts
2+
*.class
3+
4+
## Package Files
5+
*.jar
6+
*.war
7+
*.ear
8+
target
9+
10+
## IntelliJ
11+
.idea
12+
*.iml
13+
14+
## Logs
15+
*.log
16+
17+
## Temp
18+
*~
19+
.#*
20+
21+
dependency-reduced-pom.xml
22+
.factorypath
23+
.classpath
24+
.project
25+
.settings/
26+
27+
# mvn release
28+
pom.xml.releaseBackup
29+
release.properties
30+
31+
# macOS
32+
.DS_Store

.sdkmanrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Enable auto-env through the sdkman_auto_env config
2+
# Add key=value pairs of SDKs to use below
3+
java=11.0.21-amzn
4+
maven=3.8.6

0 commit comments

Comments
 (0)