-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_versions_repository.sh
More file actions
executable file
·71 lines (57 loc) · 2.13 KB
/
update_versions_repository.sh
File metadata and controls
executable file
·71 lines (57 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# This script is used to update versions respository (if )
# This way history is preserved and we can track changes
set -e
# Expecting 3 arguments:
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <DOCKER_HUB_NAMESPACE> <DOCKER_HUB_REPOSITORY> <TAG>"
exit 1
fi
DOCKER_HUB_NAMESPACE=$1
DOCKER_HUB_REPOSITORY=$2
TAG=$3
DOCKER_NAME="${DOCKER_HUB_NAMESPACE}/${DOCKER_HUB_REPOSITORY}"
VERSIONS_JSON="pdfix-version-updates/v1/versions.json"
TEMPORARY_FILE="tmp_versions.json"
# Step 1: Check if app is in version history
if jq -e --arg name "$DOCKER_NAME" '.["pdfix-actions"][] | select(.name == $name)' "$VERSIONS_JSON" > /dev/null; then
echo "App found in version history."
# Step 2: Update action version and date
TODAY=$(date +%Y-%m-%d)
jq --indent 4 --arg name "$DOCKER_NAME" --arg version "$TAG" --arg date "$TODAY" \
'(.["pdfix-actions"][] | select(.name == $name)) |= . + {
"version": $version,
"release_date": $date
}' $VERSIONS_JSON > $TEMPORARY_FILE
mv $TEMPORARY_FILE $VERSIONS_JSON
# Step 3: Commit and push changes
cd pdfix-version-updates
git config user.name "PDFix Support"
git config user.email "support@pdfix.net"
git add v1/versions.json
git commit -m "$DOCKER_NAME $TAG"
git push
# Step 4: Tag latest commit with increment
git fetch --tags
git pull
if git describe --exact-match --tags HEAD > /dev/null 2>&1; then
echo "HEAD already has a tag — skipping tagging."
else
LATEST_TAG=$(git tag -l "v*.*.*" | sort -V | tail -n 1)
if [ -z "$LATEST_TAG" ]; then
echo "No existing tags found, starting from v0.0.1"
NEW_TAG="v0.0.1"
else
echo "Latest tag is: $LATEST_TAG"
VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
PATCH=$((PATCH + 1))
NEW_TAG="v$MAJOR.$MINOR.$PATCH"
fi
git tag -a "$NEW_TAG" -m "Release $NEW_TAG"
git push origin "$NEW_TAG"
echo "Tagged HEAD with: $NEW_TAG"
fi
else
echo "App not found in version history. Skipping update steps."
fi