Skip to content

Commit

Permalink
Merge pull request #4 from a645162/dev
Browse files Browse the repository at this point in the history
feat(CI/CD): Support version Tags
  • Loading branch information
a645162 authored Sep 11, 2024
2 parents 146be03 + 30da72d commit a8b077e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
run: |
python --version
pip --version
python version.py
echo "PROGRAM_VERSION=${python version.py}" >> $GITHUB_ENV
- name: Build .jar file
run: python build_with_docker.py
Expand Down Expand Up @@ -83,7 +85,9 @@ jobs:
push: true
tags: |
${{ github.repository }}:${{ env.IMAGE_TAG }},
${{ github.repository }}:${{ env.PROGRAM_VERSION }},
${{ env.ACR_REGISTRY }}/${{ github.repository }}:${{ env.IMAGE_TAG }},
${{ env.ACR_REGISTRY }}/${{ github.repository }}:${{ env.PROGRAM_VERSION }},
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
2 changes: 1 addition & 1 deletion .run/act.docker.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="act.docker" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<configuration default="false" name="act.docker" type="PythonConfigurationType" factoryName="Python" folderName="Dev" nameIsGenerated="true">
<module name="group-center" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
Expand Down
25 changes: 25 additions & 0 deletions .run/version.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="version" type="PythonConfigurationType" factoryName="Python" folderName="Dev" nameIsGenerated="true">
<module name="group-center" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/version.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ val springBootVersion = "3.3.3"
val myBatisVersion = "3.0.3"

group = "com.khm.group"
version = "1.0.1-SNAPSHOT"
version = "1.0.2-SNAPSHOT"

java {
sourceCompatibility = JavaVersion.VERSION_21
Expand Down
10 changes: 6 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
services:
group_center:
image: group_center
build:
context: .
dockerfile: Dockerfile
image: registry.cn-shanghai.aliyuncs.com/a645162/group-center:latest
# image: a645162/group-center:latest
# image: group_center
# build:
# context: .
# dockerfile: Dockerfile
ports:
- 15090:15090
- 15092:15092
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/settings/version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0.1-SNAPSHOT
version=1.0.2-SNAPSHOT
19 changes: 19 additions & 0 deletions version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def get_version():
relative_path = "./src/main/resources/settings/version.properties"
version = "0.0.0"

with open(relative_path, "r") as f:
lines = f.readlines()
for this_line in lines:
line = this_line
line = line.strip()
if line.startswith("version="):
version = line.replace("version=", "").strip()

version = version.replace("-SNAPSHOT", "")

return version.strip()


if __name__ == "__main__":
print(get_version(), end="")

0 comments on commit a8b077e

Please sign in to comment.