From 80f060415c47eeaea85b9710b27ab88b5dd6f325 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Fri, 22 Dec 2023 14:31:37 +0200 Subject: [PATCH] ci: generate zip package and version file, add docker deployment (#687) --- .github/workflows/publish.yml | 44 +++++++++++++---- {pkgbuild => packages/aur/pkgbuild}/PKGBUILD | 0 .../chocolatey}/crowdin-cli.nuspec | 0 .../chocolatey}/tools/chocolateyinstall.ps1 | 2 +- .../chocolatey}/tools/chocolateyuninstall.ps1 | 0 packages/docker/Dockerfile | 17 +++++++ packages/zip/README.txt | 49 +++++++++++++++++++ {scripts => packages/zip}/crowdin | 0 {scripts => packages/zip}/crowdin.bat | 0 .../zip}/install-crowdin-cli.sh | 0 {scripts => packages/zip}/setup_crowdin.bat | 0 release.config.js | 12 ++--- src/main/resources/crowdin.properties | 3 +- website/docs/installation.md | 2 +- 14 files changed, 110 insertions(+), 19 deletions(-) rename {pkgbuild => packages/aur/pkgbuild}/PKGBUILD (100%) rename {chocolatey => packages/chocolatey}/crowdin-cli.nuspec (100%) rename {chocolatey => packages/chocolatey}/tools/chocolateyinstall.ps1 (86%) rename {chocolatey => packages/chocolatey}/tools/chocolateyuninstall.ps1 (100%) create mode 100644 packages/docker/Dockerfile create mode 100644 packages/zip/README.txt rename {scripts => packages/zip}/crowdin (100%) rename {scripts => packages/zip}/crowdin.bat (100%) rename {scripts => packages/zip}/install-crowdin-cli.sh (100%) rename {scripts => packages/zip}/setup_crowdin.bat (100%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a30c2f8f7..414bc1985 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,17 +22,21 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - - name: Download the latest zip - uses: carlosperate/download-file-action@v2 - with: - file-url: 'https://downloads.crowdin.com/cli/v3/crowdin-cli.zip' - - name: Generate autocomplete script run: | ./gradlew shadowJar cd build/libs java -cp crowdin-cli-*.jar picocli.AutoComplete com.crowdin.cli.commands.picocli.RootCommand + - name: Build zip package + run: | + mkdir crowdin-cli + cp build/libs/crowdin-cli-*.jar crowdin-cli/crowdin-cli.jar + cp build/libs/crowdin_completion crowdin-cli/crowdin_completion + cp packages/zip/* crowdin-cli/ + zip -r crowdin-cli.zip crowdin-cli && chmod 0644 crowdin-cli.zip + rm -rf crowdin-cli + - name: Generate shasum id: shasum run: | @@ -40,6 +44,10 @@ jobs: touch crowdin-cli_checksum.sha256 shasum -a 256 crowdin-cli.zip > crowdin-cli_checksum.sha256 + - name: Generate version.txt file + run: | + echo ${{ github.ref_name }} > version.txt + - name: Upload asset uses: softprops/action-gh-release@v1 with: @@ -47,6 +55,7 @@ jobs: crowdin-cli.zip crowdin-cli_checksum.sha256 build/libs/crowdin_completion + version.txt npm: runs-on: ubuntu-latest @@ -106,7 +115,7 @@ jobs: uses: KSXGitHub/github-actions-deploy-aur@v2.6.0 with: pkgname: crowdin-cli - pkgbuild: ./pkgbuild/PKGBUILD + pkgbuild: ./packages/aur/pkgbuild/PKGBUILD commit_username: ${{ secrets.AUR_USERNAME }} commit_email: ${{ secrets.AUR_EMAIL }} ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} @@ -136,15 +145,32 @@ jobs: - name: Update checksum run: | echo "New Hash: ${{ needs.assets.outputs.checksum }}\n" - sed -i "s/checksum = '.*'/checksum = '${{ needs.assets.outputs.checksum }}'/g" chocolatey/tools/chocolateyinstall.ps1 - cat chocolatey/tools/chocolateyinstall.ps1 + sed -i "s/checksum = '.*'/checksum = '${{ needs.assets.outputs.checksum }}'/g" packages/chocolatey/tools/chocolateyinstall.ps1 + cat packages/chocolatey/tools/chocolateyinstall.ps1 - name: Choco pack uses: crazy-max/ghaction-chocolatey@v2 with: - args: pack chocolatey/crowdin-cli.nuspec + args: pack packages/chocolatey/crowdin-cli.nuspec - name: Choco publish uses: crazy-max/ghaction-chocolatey@v2 with: args: push --api-key ${{ secrets.CHOCOLATEY_API_KEY }} --source=https://push.chocolatey.org/ + + docker: + runs-on: ubuntu-latest + needs: assets + steps: + - uses: actions/checkout@v3 + + - name: Copy Dockerfile + run: | + cp packages/docker/Dockerfile Dockerfile + + - name: Build Docker image + run: | + docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}" docker.io + docker build --pull -t "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:${{ github.ref_name }}" -t "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:latest" . + docker push "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:${{ github.ref_name }}" + docker push "${{ secrets.DOCKER_HUB_REGISTRY_IMAGE }}:latest" diff --git a/pkgbuild/PKGBUILD b/packages/aur/pkgbuild/PKGBUILD similarity index 100% rename from pkgbuild/PKGBUILD rename to packages/aur/pkgbuild/PKGBUILD diff --git a/chocolatey/crowdin-cli.nuspec b/packages/chocolatey/crowdin-cli.nuspec similarity index 100% rename from chocolatey/crowdin-cli.nuspec rename to packages/chocolatey/crowdin-cli.nuspec diff --git a/chocolatey/tools/chocolateyinstall.ps1 b/packages/chocolatey/tools/chocolateyinstall.ps1 similarity index 86% rename from chocolatey/tools/chocolateyinstall.ps1 rename to packages/chocolatey/tools/chocolateyinstall.ps1 index ad8339774..25e863756 100644 --- a/chocolatey/tools/chocolateyinstall.ps1 +++ b/packages/chocolatey/tools/chocolateyinstall.ps1 @@ -6,7 +6,7 @@ $packageVersion = $env:ChocolateyPackageVersion $packageArgs = @{ packageName = $packageName unzipLocation = $toolsDir - url = 'https://downloads.crowdin.com/cli/v3/crowdin-cli.zip' + url = 'https://github.com/crowdin/crowdin-cli/releases/latest/download/crowdin-cli.zip' checksum = '9078bcacbb481eb01fbbfaf6bef87322bb1ca8d6835b543517e913127e0089c4' checksumType = 'sha256' } diff --git a/chocolatey/tools/chocolateyuninstall.ps1 b/packages/chocolatey/tools/chocolateyuninstall.ps1 similarity index 100% rename from chocolatey/tools/chocolateyuninstall.ps1 rename to packages/chocolatey/tools/chocolateyuninstall.ps1 diff --git a/packages/docker/Dockerfile b/packages/docker/Dockerfile new file mode 100644 index 000000000..463b0d926 --- /dev/null +++ b/packages/docker/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine + +RUN apk --no-cache add sudo openjdk11-jre --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community; + +ADD https://github.com/crowdin/crowdin-cli/releases/latest/download/crowdin-cli.zip /usr/ + +RUN unzip -j /usr/crowdin-cli.zip; \ + sh install-crowdin-cli.sh; \ + rm /usr/crowdin-cli.zip; \ + rm *.*; + +RUN echo -e '#!/bin/sh\njava -jar /usr/local/bin/crowdin-cli.jar "$@"' > /usr/local/bin/crowdin; \ + chmod +x /usr/local/bin/crowdin; + +WORKDIR /usr/crowdin-project + +CMD ["sh"] diff --git a/packages/zip/README.txt b/packages/zip/README.txt new file mode 100644 index 000000000..cb0a8d96e --- /dev/null +++ b/packages/zip/README.txt @@ -0,0 +1,49 @@ +------------------------------ Crowdin CLI v3 --------------------------------- + +# Installation on Linux and MacOS + +Run `. install-crowdin-cli.sh` in the terminal with sudo rights in order to add `crowdin` command to your terminal + +------------------------------------------------------------------------------- + +# Installation on Windows + +1. Open Command Prompt as an Administrator + - Click Start + - In the Start Search box, type `cmd`, and then press CTRL+SHIFT+ENTER + - If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue + +2. Run `setup-crowdin.bat` script in order to add `crowdin` command to the Command Prompt +3. Restart your Command Prompt + +------------------------------------------------------------------------------- + +# Running the App + +Use the following method to run the app: + +- crowdin + +Alternative method: + +- java -jar crowdin-cli.jar + +------------------------------------------------------------------------------- + +# General Commands + +To display help information: + +- crowdin -h + +To generate Crowdin CLI configuration skeleton: + +- crowdin init + +To analyze your configuration file for potential errors: + +- crowdin lint + +To show a list of source files in the current project: + +- crowdin list project diff --git a/scripts/crowdin b/packages/zip/crowdin similarity index 100% rename from scripts/crowdin rename to packages/zip/crowdin diff --git a/scripts/crowdin.bat b/packages/zip/crowdin.bat similarity index 100% rename from scripts/crowdin.bat rename to packages/zip/crowdin.bat diff --git a/scripts/install-crowdin-cli.sh b/packages/zip/install-crowdin-cli.sh similarity index 100% rename from scripts/install-crowdin-cli.sh rename to packages/zip/install-crowdin-cli.sh diff --git a/scripts/setup_crowdin.bat b/packages/zip/setup_crowdin.bat similarity index 100% rename from scripts/setup_crowdin.bat rename to packages/zip/setup_crowdin.bat diff --git a/release.config.js b/release.config.js index 151bdd0eb..4ac4dee31 100644 --- a/release.config.js +++ b/release.config.js @@ -68,13 +68,13 @@ module.exports = { }, { "files": [ - "pkgbuild/PKGBUILD" + "packages/aur/pkgbuild/PKGBUILD" ], "from": "pkgver=.*", "to": "pkgver=${nextRelease.version}", "results": [ { - "file": "pkgbuild/PKGBUILD", + "file": "packages/aur/pkgbuild/PKGBUILD", "hasChanged": true, "numMatches": 1, "numReplacements": 1 @@ -84,13 +84,13 @@ module.exports = { }, { "files": [ - "chocolatey/crowdin-cli.nuspec" + "packages/chocolatey/crowdin-cli.nuspec" ], "from": ".*", "to": "${nextRelease.version}", "results": [ { - "file": "chocolatey/crowdin-cli.nuspec", + "file": "packages/chocolatey/crowdin-cli.nuspec", "hasChanged": true, "numMatches": 1, "numReplacements": 1 @@ -115,8 +115,8 @@ module.exports = { "src/main/resources/crowdin.properties", "package.json", "package-lock.json", - "pkgbuild/PKGBUILD", - "chocolatey/*", + "packages/aur/pkgbuild/PKGBUILD", + "packages/chocolatey/*", "CHANGELOG.md" ], "message": "chore(release): version ${nextRelease.version} [skip ci]" diff --git a/src/main/resources/crowdin.properties b/src/main/resources/crowdin.properties index 3fb0cceee..d2bee80e4 100755 --- a/src/main/resources/crowdin.properties +++ b/src/main/resources/crowdin.properties @@ -1,5 +1,4 @@ application.name=crowdin-cli application.version=3.15.0 application.base_url=https://api.crowdin.com -application.user_agent=crowdin-java-cli -application.version_file_url=https://downloads.crowdin.com/cli/v3/version.txt +application.version_file_url=https://github.com/crowdin/crowdin-cli/releases/latest/download/version.txt diff --git a/website/docs/installation.md b/website/docs/installation.md index 199af8989..771d64d76 100644 --- a/website/docs/installation.md +++ b/website/docs/installation.md @@ -120,7 +120,7 @@ docker pull crowdin/cli ## Standalone version -Crowdin CLI can be installed as a stand-alone Java application. [Download for macOS, Linux and Windows](https://downloads.crowdin.com/cli/v3/crowdin-cli.zip) +Crowdin CLI can be installed as a stand-alone Java application. [Download](https://github.com/crowdin/crowdin-cli/releases/latest/download/crowdin-cli.zip). ### Installation on Linux and macOS