Skip to content

Commit

Permalink
Add versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Dec 19, 2023
1 parent 65618ed commit 3259bb4
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 19 deletions.
27 changes: 27 additions & 0 deletions .github/actions/replace-text/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Replace text in file

inputs:
old-string:
description: String to replace
required: true
type: string
new-string:
description: String to replace with
required: true
type: string
file:
description: Path to file
required: true
type: string

runs:
using: composite
steps:
- name: Replace substring
shell: bash
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
sed -i '' 's/${{ inputs.old-string }}/${{ inputs.new-string }}/g' ${{ inputs.file }}
else
sed -i 's/${{ inputs.old-string }}/${{ inputs.new-string }}/g' ${{ inputs.file }}
fi
24 changes: 24 additions & 0 deletions .github/actions/replace-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Replace version

inputs:
version:
description: Version to replace with
required: true
type: string

runs:
using: composite
steps:
- name: Replace string in src/main.cpp
uses: ./.github/actions/replace-text
with:
file: src/main.cpp
old-string: <local-build>
new-string: ${{ inputs.version }}

- name: Replace string in bin/lottie_common.sh
uses: ./.github/actions/replace-text
with:
file: bin/lottie_common.sh
old-string: <local-build>
new-string: ${{ inputs.version }}
10 changes: 10 additions & 0 deletions .github/workflows/build-darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: Name of artifact as which Darwin executable to be uploaded
required: true
type: string
version:
description: Version to replace with
required: false
type: string

jobs:
build-darwin:
Expand All @@ -18,6 +22,12 @@ jobs:

- uses: actions/checkout@v3

- name: Replace version
if: ${{ inputs.version != '' }}
uses: ./.github/actions/replace-version
with:
version: ${{ inputs.version }}

- name: Detect conan profile
run: conan profile detect

Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/build-linux-and-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: "amd64 or arm64"
required: true
type: string
version:
description: Version to replace with
required: false
type: string

jobs:
build-docker:
Expand All @@ -27,6 +31,12 @@ jobs:
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Replace version
if: ${{ inputs.version != '' }}
uses: ./.github/actions/replace-version
with:
version: ${{ inputs.version }}

- name: Build lottie-to-apng
uses: docker/build-push-action@v4
with:
Expand All @@ -37,7 +47,7 @@ jobs:
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload lottie-to-apng as artifact
uses: ishworkh/container-image-artifact-upload@v1.0.0
with:
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ on:
description: Name of artifact as which Windows executable to be uploaded
required: true
type: string

version:
description: Version to replace with
required: false
type: string
jobs:
build-windows:
name: Build Windows executable
Expand All @@ -18,6 +21,12 @@ jobs:

- uses: actions/checkout@v3

- name: Replace version
if: ${{ inputs.version != '' }}
uses: ./.github/actions/replace-version
with:
version: ${{ inputs.version }}

- name: Detect conan profile
run: conan profile detect

Expand Down
42 changes: 28 additions & 14 deletions .github/workflows/cd-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ jobs:
with:
output-artifact-name: lottie-to-png.linux.${{ matrix.arch }}
arch: ${{ matrix.arch }}
version: ${{ github.ref_name }}

build-darwin:
name: Build Darwin executable
uses: ./.github/workflows/build-darwin.yml
with:
output-artifact-name: lottie-to-png.darwin.amd64
version: ${{ github.ref_name }}

build-windows:
name: Build Windows executable
uses: ./.github/workflows/build-windows.yml
with:
output-artifact-name: lottie-to-png.windows.amd64.exe
version: ${{ github.ref_name }}

push-docker-image:
name: Push images to DockerHub
Expand Down Expand Up @@ -80,39 +83,45 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create manifest
- name: Create manifest of latest tag
run: docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:latest --amend ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:amd64 --amend ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:arm64

- name: Push manifest
- name: Push manifest of latest tag
run: docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:latest

- name: Create manifest of version tag
run: docker manifest create ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:${{ github.ref_name }} --amend ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:amd64 --amend ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:arm64

- name: Push manifest of version tag
run: docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:${{ github.ref_name }}

- name: Make format uppercase
id: format
uses: ASzc/change-string-case-action@v5
with:
string: ${{ matrix.format }}

- uses: actions/checkout@v4
- name: Find and replace FORMAT
uses: jacobtomlinson/gha-find-replace@v3

- name: Find and replace FORMAT in readme for DockerHub
uses: ./.github/actions/replace-text
with:
find: FORMAT
replace: ${{ steps.format.outputs.uppercase }}
regex: false
file: README.dockerhub.md
old-string: FORMAT
new-string: ${{ steps.format.outputs.uppercase }}

- name: Find and replace format
uses: jacobtomlinson/gha-find-replace@v3
- name: Find and replace format in readme for DockerHub
uses: ./.github/actions/replace-text
with:
find: format
replace: ${{ matrix.format }}
regex: false
file: README.dockerhub.md
old-string: format
new-string: ${{ matrix.format }}

- name: Update description at DockerHub
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}
short-description: Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) to ${{ steps.format.outputs.uppercase }}}
readme-filepath: README.dockerhub.md
Expand All @@ -136,6 +145,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Replace version
uses: ./.github/actions/replace-version
with:
version: ${{ github.ref_name }}

- name: Download artifact
uses: actions/download-artifact@v3
with:
Expand Down
16 changes: 14 additions & 2 deletions bin/lottie_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ function print_help() {
echo " path Path to .json or .tgs file to convert"
echo
echo "Optional arguments:"
echo " -h, --help show this help message and exit"
echo " -h, --help shows this help message and exits"
echo " -v, --version prints version information and exits"
echo " --output OUTPUT Output file path"
echo " --height HEIGHT Output image height. Default: $HEIGHT"
echo " --width WIDTH Output image width. Default: $WIDTH"
echo " --fps FPS Output frame rate. Default: $FPS"
echo " --threads THREADS Number of threads to use. Default: number of CPUs"
echo " --quality QUALITY Output quality. Default: $QUALITY"
echo
echo "It's open-source project: https://github.com/ed-asriyan/lottie-converter"
echo "Author: Ed Asriyan <contact.lottie-converter@asriyan.me>"
}

function print_version() {
echo "<local-build>"
}

while [[ $# -gt 0 ]]; do
Expand Down Expand Up @@ -60,10 +68,14 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--help)
-h|--help)
print_help
exit 1
;;
-v|--version)
print_version
exit 1
;;
*)
POSITIONAL_ARG=$1
shift
Expand Down
12 changes: 11 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ void convert(
}

int main(int argc, const char** argv) {
argparse::ArgumentParser program("lottie_to_png");
argparse::ArgumentParser program("lottie_to_png", "<local-build>");

program.add_description(
"Lottie animations (.json) to frames as .png files converter.\n"
"This executable is one of components of lottie-converter project and isn't supposed to be used directly."
);

program.add_epilog(
"It's open-source project: https://github.com/ed-asriyan/lottie-converter\n"
"Author: Ed Asriyan <contact.lottie-converter@asriyan.me>"
);

program.add_argument("path")
.required()
Expand Down

0 comments on commit 3259bb4

Please sign in to comment.