Skip to content

Commit 3259bb4

Browse files
committed
Add versioning
1 parent 65618ed commit 3259bb4

8 files changed

Lines changed: 135 additions & 19 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Replace text in file
2+
3+
inputs:
4+
old-string:
5+
description: String to replace
6+
required: true
7+
type: string
8+
new-string:
9+
description: String to replace with
10+
required: true
11+
type: string
12+
file:
13+
description: Path to file
14+
required: true
15+
type: string
16+
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Replace substring
21+
shell: bash
22+
run: |
23+
if [ "$RUNNER_OS" == "macOS" ]; then
24+
sed -i '' 's/${{ inputs.old-string }}/${{ inputs.new-string }}/g' ${{ inputs.file }}
25+
else
26+
sed -i 's/${{ inputs.old-string }}/${{ inputs.new-string }}/g' ${{ inputs.file }}
27+
fi
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Replace version
2+
3+
inputs:
4+
version:
5+
description: Version to replace with
6+
required: true
7+
type: string
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Replace string in src/main.cpp
13+
uses: ./.github/actions/replace-text
14+
with:
15+
file: src/main.cpp
16+
old-string: <local-build>
17+
new-string: ${{ inputs.version }}
18+
19+
- name: Replace string in bin/lottie_common.sh
20+
uses: ./.github/actions/replace-text
21+
with:
22+
file: bin/lottie_common.sh
23+
old-string: <local-build>
24+
new-string: ${{ inputs.version }}

.github/workflows/build-darwin.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: Name of artifact as which Darwin executable to be uploaded
88
required: true
99
type: string
10+
version:
11+
description: Version to replace with
12+
required: false
13+
type: string
1014

1115
jobs:
1216
build-darwin:
@@ -18,6 +22,12 @@ jobs:
1822

1923
- uses: actions/checkout@v3
2024

25+
- name: Replace version
26+
if: ${{ inputs.version != '' }}
27+
uses: ./.github/actions/replace-version
28+
with:
29+
version: ${{ inputs.version }}
30+
2131
- name: Detect conan profile
2232
run: conan profile detect
2333

.github/workflows/build-linux-and-docker.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: "amd64 or arm64"
1212
required: true
1313
type: string
14+
version:
15+
description: Version to replace with
16+
required: false
17+
type: string
1418

1519
jobs:
1620
build-docker:
@@ -27,6 +31,12 @@ jobs:
2731
- name: Setup Docker buildx
2832
uses: docker/setup-buildx-action@v2
2933

34+
- name: Replace version
35+
if: ${{ inputs.version != '' }}
36+
uses: ./.github/actions/replace-version
37+
with:
38+
version: ${{ inputs.version }}
39+
3040
- name: Build lottie-to-apng
3141
uses: docker/build-push-action@v4
3242
with:
@@ -37,7 +47,7 @@ jobs:
3747
load: true
3848
cache-from: type=gha
3949
cache-to: type=gha,mode=max
40-
50+
4151
- name: Upload lottie-to-apng as artifact
4252
uses: ishworkh/container-image-artifact-upload@v1.0.0
4353
with:

.github/workflows/build-windows.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ on:
77
description: Name of artifact as which Windows executable to be uploaded
88
required: true
99
type: string
10-
10+
version:
11+
description: Version to replace with
12+
required: false
13+
type: string
1114
jobs:
1215
build-windows:
1316
name: Build Windows executable
@@ -18,6 +21,12 @@ jobs:
1821

1922
- uses: actions/checkout@v3
2023

24+
- name: Replace version
25+
if: ${{ inputs.version != '' }}
26+
uses: ./.github/actions/replace-version
27+
with:
28+
version: ${{ inputs.version }}
29+
2130
- name: Detect conan profile
2231
run: conan profile detect
2332

.github/workflows/cd-release.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ jobs:
1717
with:
1818
output-artifact-name: lottie-to-png.linux.${{ matrix.arch }}
1919
arch: ${{ matrix.arch }}
20+
version: ${{ github.ref_name }}
2021

2122
build-darwin:
2223
name: Build Darwin executable
2324
uses: ./.github/workflows/build-darwin.yml
2425
with:
2526
output-artifact-name: lottie-to-png.darwin.amd64
27+
version: ${{ github.ref_name }}
2628

2729
build-windows:
2830
name: Build Windows executable
2931
uses: ./.github/workflows/build-windows.yml
3032
with:
3133
output-artifact-name: lottie-to-png.windows.amd64.exe
34+
version: ${{ github.ref_name }}
3235

3336
push-docker-image:
3437
name: Push images to DockerHub
@@ -80,39 +83,45 @@ jobs:
8083
username: ${{ secrets.DOCKERHUB_USERNAME }}
8184
password: ${{ secrets.DOCKERHUB_TOKEN }}
8285

83-
- name: Create manifest
86+
- name: Create manifest of latest tag
8487
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
8588

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

92+
- name: Create manifest of version tag
93+
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
94+
95+
- name: Push manifest of version tag
96+
run: docker manifest push ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-${{ matrix.format }}:${{ github.ref_name }}
97+
8998
- name: Make format uppercase
9099
id: format
91100
uses: ASzc/change-string-case-action@v5
92101
with:
93102
string: ${{ matrix.format }}
94103

95104
- uses: actions/checkout@v4
96-
97-
- name: Find and replace FORMAT
98-
uses: jacobtomlinson/gha-find-replace@v3
105+
106+
- name: Find and replace FORMAT in readme for DockerHub
107+
uses: ./.github/actions/replace-text
99108
with:
100-
find: FORMAT
101-
replace: ${{ steps.format.outputs.uppercase }}
102-
regex: false
109+
file: README.dockerhub.md
110+
old-string: FORMAT
111+
new-string: ${{ steps.format.outputs.uppercase }}
103112

104-
- name: Find and replace format
105-
uses: jacobtomlinson/gha-find-replace@v3
113+
- name: Find and replace format in readme for DockerHub
114+
uses: ./.github/actions/replace-text
106115
with:
107-
find: format
108-
replace: ${{ matrix.format }}
109-
regex: false
116+
file: README.dockerhub.md
117+
old-string: format
118+
new-string: ${{ matrix.format }}
110119

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

148+
- name: Replace version
149+
uses: ./.github/actions/replace-version
150+
with:
151+
version: ${{ github.ref_name }}
152+
139153
- name: Download artifact
140154
uses: actions/download-artifact@v3
141155
with:

bin/lottie_common.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,21 @@ function print_help() {
1919
echo " path Path to .json or .tgs file to convert"
2020
echo
2121
echo "Optional arguments:"
22-
echo " -h, --help show this help message and exit"
22+
echo " -h, --help shows this help message and exits"
23+
echo " -v, --version prints version information and exits"
2324
echo " --output OUTPUT Output file path"
2425
echo " --height HEIGHT Output image height. Default: $HEIGHT"
2526
echo " --width WIDTH Output image width. Default: $WIDTH"
2627
echo " --fps FPS Output frame rate. Default: $FPS"
2728
echo " --threads THREADS Number of threads to use. Default: number of CPUs"
2829
echo " --quality QUALITY Output quality. Default: $QUALITY"
30+
echo
31+
echo "It's open-source project: https://github.com/ed-asriyan/lottie-converter"
32+
echo "Author: Ed Asriyan <contact.lottie-converter@asriyan.me>"
33+
}
34+
35+
function print_version() {
36+
echo "<local-build>"
2937
}
3038

3139
while [[ $# -gt 0 ]]; do
@@ -60,10 +68,14 @@ while [[ $# -gt 0 ]]; do
6068
shift
6169
shift
6270
;;
63-
--help)
71+
-h|--help)
6472
print_help
6573
exit 1
6674
;;
75+
-v|--version)
76+
print_version
77+
exit 1
78+
;;
6779
*)
6880
POSITIONAL_ARG=$1
6981
shift

src/main.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ void convert(
3535
}
3636

3737
int main(int argc, const char** argv) {
38-
argparse::ArgumentParser program("lottie_to_png");
38+
argparse::ArgumentParser program("lottie_to_png", "<local-build>");
39+
40+
program.add_description(
41+
"Lottie animations (.json) to frames as .png files converter.\n"
42+
"This executable is one of components of lottie-converter project and isn't supposed to be used directly."
43+
);
44+
45+
program.add_epilog(
46+
"It's open-source project: https://github.com/ed-asriyan/lottie-converter\n"
47+
"Author: Ed Asriyan <contact.lottie-converter@asriyan.me>"
48+
);
3949

4050
program.add_argument("path")
4151
.required()

0 commit comments

Comments
 (0)