diff --git a/.github/workflows/_discussions.txt b/.github/workflows/_discussions.txt new file mode 100644 index 0000000..04f5630 --- /dev/null +++ b/.github/workflows/_discussions.txt @@ -0,0 +1,8 @@ + +All workflows that will be called before pr should be called from ci-pr.yml. +All workflows that will be called after pushing to main should be called from ci-push.yml. + +Tests, linters and other quality assurance for module should run inside of workflow named "quality-assurance.yml". +Building and deploying artifact logic for module should run inside of workflow named "deploy.yml". + +For version validation you should specify version obtaining logic in .vuh file. \ No newline at end of file diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 0000000..25aeb16 --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -0,0 +1,18 @@ +name: ci + +on: + pull_request: + branches: [ main ] + +jobs: + + validate-version: + name: Validate version + uses: ./.github/workflows/validate-current-version.yml + with: + VUH_VERSION: 'v2.9.2' + + quality-assurance-api: + name: Quality assurance + uses: ./.github/workflows/quality-assurance.yml + needs: validate-version diff --git a/.github/workflows/ci-push.yml b/.github/workflows/ci-push.yml new file mode 100644 index 0000000..a47857b --- /dev/null +++ b/.github/workflows/ci-push.yml @@ -0,0 +1,24 @@ +name: ci + +on: + push: + branches: [ main ] + +jobs: + + deploy: + name: Deploy mellophone2 + uses: ./.github/workflows/deploy.yml + with: + VUH_VERSION: 'v2.9.2' + secrets: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + release-notes-generation: + name: Release generation + uses: ./.github/workflows/release-notes-generation.yml + with: + VUH_VERSION: 'v2.9.2' + CHANGELOG_GENERATOR_VERSION: 'v1.0.2' + needs: [deploy] diff --git a/.github/workflows/ci-mellophone2-prod.yml b/.github/workflows/deploy.yml similarity index 55% rename from .github/workflows/ci-mellophone2-prod.yml rename to .github/workflows/deploy.yml index af14131..03b1451 100644 --- a/.github/workflows/ci-mellophone2-prod.yml +++ b/.github/workflows/deploy.yml @@ -1,46 +1,58 @@ # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven -name: ci-mellophone2-prod +name: Deploy mellophone2 -# Triggers the workflow on push or pull request events but only for the master branch on: - push: - branches: [ main ] + workflow_call: + inputs: + VUH_VERSION: { required: true, type: string } + secrets: + DOCKER_USERNAME: + required: true + DOCKER_PASSWORD: + required: true -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" build: - + name: Deploy mellophone2 runs-on: ubuntu-latest - + environment: deployenv steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Download vuh + run: | + curl https://raw.githubusercontent.com/Greewil/version-update-helper/${{ inputs.VUH_VERSION }}/vuh.sh -O -J -L + chmod +x vuh.sh + - name: Get release version + id: artifact_version + run: | + cur_version=$(./vuh.sh lv -q) + echo "release version: $cur_version" + echo "VERSION=$cur_version" >> "$GITHUB_OUTPUT" - name: Set up JDK 17 enviroment on ubuntu-latest... uses: actions/setup-java@v2 with: java-version: '17' distribution: 'temurin' cache: maven + - name: Build mellophone2 with maven run: mvn clean package - - name: Extract pom project version - run: echo ::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) - id: projectversiongroup - uses: papeloto/action-zip@v1 with: files: - target/mellophone2-${{ steps.projectversiongroup.outputs.version }}.jar + target/mellophone2-${{ steps.artifact_version.outputs.VERSION }}.jar target/classes/application.yml target/classes/config/config.xml - dest: ./artifact_for_ftp/mellophone2-${{ steps.projectversiongroup.outputs.version }}.zip + dest: ./artifact_for_ftp/mellophone2-${{ steps.artifact_version.outputs.VERSION }}.zip - name: Archive production artifacts uses: actions/upload-artifact@v4 with: - name: mellophone2-${{ steps.projectversiongroup.outputs.version }} - path: ./artifact_for_ftp/mellophone2-${{ steps.projectversiongroup.outputs.version }}.zip + name: mellophone2-${{ steps.artifact_version.outputs.VERSION }} + path: ./artifact_for_ftp/mellophone2-${{ steps.artifact_version.outputs.VERSION }}.zip + - name: πŸ“‚ Upload artifact to ftp uses: SamKirkland/FTP-Deploy-Action@4.0.0 with: @@ -49,19 +61,21 @@ jobs: password: ${{ secrets.FTP_CURS_PWD }} server-dir: development/curs-mellophone2/ local-dir: ./artifact_for_ftp/ - - name: Build docker image - run: | - docker build -t curs/mellophone2 . - - name: Log in to Docker Hub + + - name: Login to container registry (to Docker Hub) if: success() && github.ref == 'refs/heads/main' - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push + - name: Build and push if: success() && github.ref == 'refs/heads/main' - run: | - docker push curs/mellophone2:latest + uses: docker/build-push-action@v6 + with: + push: true + tags: curs/mellophone2:latest , curs/mellophone2:${{ steps.artifact_version.outputs.VERSION }} + context: . + - name: Build documentation run: | ./_builddoc.sh diff --git a/.github/workflows/ci-mellophone2-pr.yml b/.github/workflows/quality-assurance.yml similarity index 78% rename from .github/workflows/ci-mellophone2-pr.yml rename to .github/workflows/quality-assurance.yml index b9b49a9..169ff7a 100644 --- a/.github/workflows/ci-mellophone2-pr.yml +++ b/.github/workflows/quality-assurance.yml @@ -1,28 +1,30 @@ # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven -name: ci-mellophone2-pr +name: Quality Assurance API on: - pull_request: - branches: [ main ] + workflow_call: jobs: build: - + name: Quality Assurance API runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Set up JDK 17 enviroment on ubuntu-latest... uses: actions/setup-java@v2 with: java-version: '17' distribution: 'temurin' cache: maven - - name: Build mellophone2 with maven + + - name: Build mellophone2 with maven and run tests run: mvn clean test + - name: Build documentation run: | ./_builddoc.sh diff --git a/.github/workflows/release-notes-generation.yml b/.github/workflows/release-notes-generation.yml new file mode 100644 index 0000000..198792d --- /dev/null +++ b/.github/workflows/release-notes-generation.yml @@ -0,0 +1,59 @@ +name: Release generation + +on: + workflow_call: + inputs: + VUH_VERSION: { required: true, type: string } + CHANGELOG_GENERATOR_VERSION: { required: true, type: string } + +jobs: + + generate_release_from_new_commits: + runs-on: ubuntu-latest + steps: + + - name: Git clone this repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: download vuh + run: | + curl https://raw.githubusercontent.com/Greewil/version-update-helper/${{ inputs.VUH_VERSION }}/vuh.sh -O -J -L + chmod +x vuh.sh + + - name: download release notes generator + run: | + curl https://raw.githubusercontent.com/Greewil/release-notes-generator/${{ inputs.CHANGELOG_GENERATOR_VERSION }}/gen_release_notes.sh -O -J -L + chmod +x gen_release_notes.sh + + - name: get release tag_name + id: release_tag + run: | + cur_version=$(./vuh.sh lv -q) + [ "$cur_version" != '' ] || exit 1 + echo "release version: $cur_version" + echo "RELEASE_TAG=$cur_version" >> "$GITHUB_OUTPUT" + + - name: generate release notes + id: changelog + run: | + ./gen_release_notes.sh -i .. -lt -f changelog.md + [ -f "changelog.md" ] && CHANGELOG=$(cat changelog.md) || CHANGELOG='' + echo "$CHANGELOG" + echo 'FINAL_CHANGELOG<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + [ -f 'changelog.md' ] && echo "IS_EMPTY=false" >> "$GITHUB_OUTPUT" + [ -f 'changelog.md' ] || echo "IS_EMPTY=true" >> "$GITHUB_OUTPUT" + + - name: Create Release + uses: actions/create-release@v1 + if: ${{ steps.changelog.outputs.IS_EMPTY == 'false' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "${{ steps.release_tag.outputs.RELEASE_TAG }}" + release_name: "${{ steps.release_tag.outputs.RELEASE_TAG }}" + body: ${{ steps.changelog.outputs.FINAL_CHANGELOG }} diff --git a/.github/workflows/validate-current-version.yml b/.github/workflows/validate-current-version.yml new file mode 100644 index 0000000..91d99e0 --- /dev/null +++ b/.github/workflows/validate-current-version.yml @@ -0,0 +1,26 @@ +name: Check new version is greater than main version + +on: + workflow_call: + inputs: + VUH_VERSION: { required: true, type: string } + +jobs: + + validate-version: + name: Check new version is greater than main version + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download vuh + run: | + curl https://raw.githubusercontent.com/Greewil/version-update-helper/${{ inputs.VUH_VERSION }}/vuh.sh -O -J -L + chmod +x vuh.sh + + - name: Compare versions + run: | + ./vuh.sh sv -q && [ "$(./vuh.sh lv -q)" = "$(./vuh.sh sv -q)" ] || exit 1 diff --git a/.vuh b/.vuh new file mode 100644 index 0000000..bf0b29d --- /dev/null +++ b/.vuh @@ -0,0 +1,16 @@ +# This is version update helper config. +# It contains specific to current project variables. With use of this file vuh understands how to extract project's +# version and where project's version variable is located. Vuh can't work with any project without this file! +# If .vuh file located in comparing branch is different from local .vuh file vuh will by default take +# configuration files from handling branches (f.e. local .vuh to work with local version and origin/main:.vuh +# to work with origin/main's version). If your project dont have .vuh file in project's root folder vuh will advice +# you to configure that project. +# +# (Version update helper's page: https://github.com/Greewil/version-update-helper) + +# This configuration file is based on project-config-templates/xml-versions-template. + +MAIN_BRANCH_NAME='main' +VERSION_FILE='pom.xml' +TEXT_BEFORE_VERSION_CODE='' +TEXT_AFTER_VERSION_CODE='<\/version>' diff --git a/README.adoc b/README.adoc index a5dc6e8..0dc4cbe 100644 --- a/README.adoc +++ b/README.adoc @@ -19,7 +19,7 @@ You may check mellophone is running by issuing the following http request: [source] ---- -http://localhost:8082/mellophone/login?sesid=123&login=login&pwd=pwd +http://localhost:8082/mellophone/login?sesid=123&login=user222&pwd=pwd222 ---- If credentials are correct you will get 200 response, otherwise you will get 403 error. diff --git a/doc/pages/general.adoc b/doc/pages/general.adoc index fe4b9fb..2ac0e1e 100644 --- a/doc/pages/general.adoc +++ b/doc/pages/general.adoc @@ -35,4 +35,7 @@ ** сСрвлСты, ΠΎΠ±ΡΠ»ΡƒΠΆΠΈΠ²Π°ΡŽΡ‰ΠΈΠ΅ прямыС запросы с сСрвСров Π²Π΅Π±-ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ; ** ΠΎΠ΄ΠΈΠ½ сСрвлСт, ΠΎΠ±ΡΠ»ΡƒΠΆΠΈΠ²Π°ΡŽΡ‰ΠΈΠΉ запросы ΠΎΡ‚ клиСнтских Π±Ρ€Π°ΡƒΠ·Π΅Ρ€ΠΎΠ², ΠΏΠΎΡΡ‚ΡƒΠΏΠ°ΡŽΡ‰ΠΈΡ… Π² Π²ΠΈΠ΄Π΅ запросов Π½Π° ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ Ρ„Ρ€Π΅ΠΉΠΌΠ° ΠΈΠ»ΠΈ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ Π½Π° страницС Π²Π΅Π±-прилоТСния. * ΠŸΡ€ΠΎΡ‚ΠΎΠΊΠΎΠ», ΠΏΠΎ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌΡƒ любоС Π²Π΅Π±-ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΌΠΎΠΆΠ΅Ρ‚ Π²Π·Π°ΠΈΠΌΠΎΠ΄Π΅ΠΉΡΡ‚Π²ΠΎΠ²Π°Ρ‚ΡŒ с сСрвСром Π°ΡƒΡ‚Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ†ΠΈΠΈ для обСспСчСния ΠΎΠ±Ρ‰Π΅ΠΉ Π°ΡƒΡ‚Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ†ΠΈΠΈ. -## \ No newline at end of file +## + +Для использования ΠΌΠ΅Ρ‚ΠΎΠ΄Π° /authentication.gif mellophone ΠΏΠΎΡ‚Ρ€Π΅Π±ΡƒΠ΅Ρ‚ наличия ssl сСртификата для https соСдиннСия. +Для этого ΠΌΠΎΠΆΠ½ΠΎ Π±ΡƒΠ΄Π΅Ρ‚ Π»ΠΈΠ±ΠΎ Π½Π°ΡΡ‚Ρ€ΠΎΠΈΡ‚ΡŒ соСдинСниС Π½Π° внСшнСм Π²Π΅Π± сСрвСрС (Ρ‡Π΅Ρ€Π΅Π· ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ запросы проходят Π½Π° mellophone), Π»ΠΈΠ±ΠΎ Π½Π°ΡΡ‚Ρ€ΠΎΠΈΡ‚ΡŒ сам mellophone (настройки tomcat для spring boot Π² application.yml), Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΎΠ½ использовал сСритификат. diff --git a/docker-example-config/application.yml b/docker-example-config/application.yml index 855e391..7ad7aa4 100644 --- a/docker-example-config/application.yml +++ b/docker-example-config/application.yml @@ -1,5 +1,7 @@ server: port: 8082 + ssl: + enabled: false mellophone: diff --git a/pom.xml b/pom.xml index ba48c41..3b55dee 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ru.curs mellophone2 - 1.5.0 + 1.6.0 UTF-8 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 16262ed..e239b32 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,8 +2,10 @@ # port: 8082 server: - port: 443 +# port: 443 + port: 8082 ssl: + enabled: false key-store: keystore.p12 key-store-password: sdgdhfjhjghjghjghjgh keyStoreType: PKCS12 @@ -13,7 +15,8 @@ server: mellophone: - configFile: D:/IdeaProjects/mellophone2/src/main/resources/config/config.xml + configFile: src/main/resources/config/config.xml +# configFile: D:/IdeaProjects/mellophone2/src/main/resources/config/config.xml