Publish #30
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
description: 'Package to publish' | |
type: choice | |
required: true | |
default: 'all' | |
options: | |
- 'all' | |
- 'npm' | |
- 'aur' | |
- 'homebrew' | |
- 'chocolatey' | |
- 'docker' | |
release: | |
types: [released] | |
jobs: | |
assets: | |
runs-on: ubuntu-latest | |
outputs: | |
checksum: ${{ steps.shasum.outputs.hash }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 8 | |
cache: 'gradle' | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- 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: | | |
echo hash=$(shasum -a 256 crowdin-cli.zip | cut -f 1 -d " ") >> $GITHUB_OUTPUT | |
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 | |
if: github.event_name == 'release' | |
with: | |
files: | | |
crowdin-cli.zip | |
crowdin-cli_checksum.sha256 | |
build/libs/crowdin_completion | |
version.txt | |
npm: | |
runs-on: ubuntu-latest | |
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'npm' | |
needs: assets | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 8 | |
cache: 'gradle' | |
- name: Generate autocomplete script | |
run: | | |
./gradlew shadowJar | |
cd build/libs | |
java -cp crowdin-cli-*.jar picocli.AutoComplete com.crowdin.cli.commands.picocli.RootCommand | |
- name: Prepare distribution | |
run: | | |
mkdir dist | |
mv build/libs/crowdin-cli-*.jar dist/crowdin-cli.jar | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install the latest version of the npm CLI | |
run: npm install -g npm@latest | |
- name: Build and install the package | |
run: | | |
sudo npm install --location=global [email protected] | |
npm install | |
jdeploy install | |
mv build/libs/crowdin_completion jdeploy-bundle/crowdin_completion | |
- name: Test crowdin command | |
run: crowdin -V | |
- name: Publish the package | |
uses: JS-DevTools/npm-publish@v2 | |
with: | |
provenance: true | |
token: ${{ secrets.NPM_TOKEN }} | |
aur: | |
runs-on: ubuntu-latest | |
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'aur' | |
needs: assets | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Publish AUR package | |
uses: KSXGitHub/[email protected] | |
with: | |
pkgname: crowdin-cli | |
pkgbuild: ./packages/aur/pkgbuild/PKGBUILD | |
commit_username: ${{ secrets.AUR_USERNAME }} | |
commit_email: ${{ secrets.AUR_EMAIL }} | |
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} | |
commit_message: Update AUR package | |
ssh_keyscan_types: rsa,dsa,ecdsa,ed25519 | |
homebrew: | |
runs-on: ubuntu-latest | |
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'homebrew' | |
needs: assets | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Invoke workflow in the homebrew-crowdin repo | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: publish.yml | |
repo: crowdin/homebrew-crowdin | |
ref: refs/heads/master | |
token: ${{ secrets.GH_HOMEBREW_TOKEN }} | |
inputs: '{ "version": "${{ github.ref_name }}" }' | |
chocolatey: | |
runs-on: windows-latest | |
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'chocolatey' | |
needs: assets | |
steps: | |
- uses: actions/checkout@v4 | |
- name: move packages/chocolatey to chocolatey | |
run: | | |
mv packages/chocolatey chocolatey | |
- name: Get latest checksum | |
id: shasum | |
run: | | |
curl -LJO https://github.com/crowdin/crowdin-cli/releases/latest/download/crowdin-cli_checksum.sha256 | |
echo hash=$(cat crowdin-cli_checksum.sha256 | cut -f 1 -d " ") >> $GITHUB_OUTPUT | |
- name: Update checksum (from release) | |
run: sed -i "s/checksum = '.*'/checksum = '${{ steps.shasum.outputs.hash }}'/g" chocolatey/tools/chocolateyinstall.ps1 | |
- name: Check chocolateyinstall | |
run: cat chocolatey/tools/chocolateyinstall.ps1 | |
- name: Choco pack | |
uses: crazy-max/ghaction-chocolatey@v2 | |
with: | |
args: pack 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 | |
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'docker' | |
needs: assets | |
steps: | |
- uses: actions/checkout@v4 | |
- 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" |