Skip to content

Publish

Publish #55

Workflow file for this run

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@v4
with:
distribution: temurin
java-version: 17
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: Build zip package
if: github.event_name == 'release'
run: |
mkdir ${{ github.ref_name }}
cp build/libs/crowdin-cli-*.jar ${{ github.ref_name }}/crowdin-cli.jar
cp build/libs/crowdin_completion ${{ github.ref_name }}/crowdin_completion
cp packages/zip/* ${{ github.ref_name }}/
zip -r crowdin-cli.zip ${{ github.ref_name }} && chmod 0644 crowdin-cli.zip
rm -rf ${{ github.ref_name }}
- name: Generate shasum
id: shasum
if: github.event_name == 'release'
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
if: github.event_name == 'release'
run: echo ${{ github.ref_name }} > version.txt
- name: Upload asset
uses: softprops/action-gh-release@v2
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_name == 'release' || 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@v4
with:
distribution: temurin
java-version: 17
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: 20
- 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@v3
with:
provenance: true
token: ${{ secrets.NPM_TOKEN }}
aur:
runs-on: ubuntu-latest
if: github.event_name == 'release' || 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_name == 'release' || 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_name == 'release' || 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
# We need to update the checksum in the 'chocolateyinstall.ps1' file.
# In case of manual deploy from branch, don't forget to update the checksum manually before deploying (get it from the latest release assets).
- name: Update checksum
if: github.event_name == 'release'
run: |
echo "New Hash: ${{ needs.assets.outputs.checksum }}\n"
sed -i "s/checksum = '.*'/checksum = '${{ needs.assets.outputs.checksum }}'/g" chocolatey/tools/chocolateyinstall.ps1
- name: check chocolateyinstall.ps1
run: cat chocolatey/tools/chocolateyinstall.ps1
- name: Choco pack
uses: crazy-max/ghaction-chocolatey@v3
with:
args: pack chocolatey/crowdin-cli.nuspec
- name: install local package
run: |
choco install temurin17
choco install crowdin-cli -s . -y
- name: Choco publish
uses: crazy-max/ghaction-chocolatey@v3
with:
args: push --api-key ${{ secrets.CHOCOLATEY_API_KEY }} --source=https://push.chocolatey.org/
docker:
runs-on: ubuntu-latest
if: github.event_name == 'release' || 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"