99 description : " CrowdSec version/tag to deploy (e.g. v1.6.0). Leave empty to deploy latest release."
1010 required : false
1111 type : string
12+ date :
13+ description : " Deployment date (YYYY-MM-DDTHH:MM:SSZ). Cannot be empty if version is not empty."
14+ required : false
15+ type : string
1216
1317jobs :
1418 deploy :
@@ -19,32 +23,42 @@ jobs:
1923 steps :
2024 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2125
22- - uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
26+ - uses : actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v4
2327 with :
2428 node-version : 20
2529
2630 - name : Pick CrowdSec version
2731 id : pick_version
2832 env :
2933 INPUT_VERSION : ${{ inputs.version }}
34+ INPUT_DATE : ${{ inputs.date }}
3035 GH_TOKEN : ${{ github.token }}
3136 run : |
3237 set -euo pipefail
3338
39+ if [ -n "${INPUT_VERSION:-}" ] && [ -z "${INPUT_DATE:-}" ]; then
40+ echo "Error: If version is provided, date must also be provided." >&2
41+ exit 1
42+ fi
43+
3444 if [ -n "${INPUT_VERSION:-}" ]; then
3545 TAG="${INPUT_VERSION}"
46+ DATE="${INPUT_DATE}"
3647 else
3748 # latest non-prerelease tag
38- TAG="$(gh release list --json tagName --exclude-pre-releases --limit 1 | jq -r '.[0].tagName')"
49+ JSON_CONTENT="$(gh release list --json tagName,publishedAt --exclude-pre-releases --limit 1)"
50+ TAG="$(echo "$JSON_CONTENT" | jq -r '.[0].tagName')"
51+ DATE="$(echo "$JSON_CONTENT" | jq -r '.[0].publishedAt')"
3952 fi
4053
4154 echo "tag=$TAG" >> "$GITHUB_OUTPUT"
55+ echo "date=$DATE" >> "$GITHUB_OUTPUT"
4256
4357 - name : Write dist artifact
4458 run : |
4559 set -euo pipefail
4660 mkdir -p ./dist
47- echo '{"name":"${{ steps.pick_version.outputs.tag }}"}' > ./dist/latest
61+ echo '{"name":"${{ steps.pick_version.outputs.tag }}", "tag_name":"${{ steps.pick_version.outputs.tag }}", "published_at":"${{ steps.pick_version.outputs.date }}" }' > ./dist/latest
4862 cat ./dist/latest
4963
5064 # Deploy the build output directory (adjust ./dist to your framework output)
0 commit comments