Skip to content

Commit 1df2c55

Browse files
authored
CI: add published_at to version.crowdsec.net/latest (#4291)
1 parent 43f7a1e commit 1df2c55

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/version.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
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

1317
jobs:
1418
deploy:
@@ -27,24 +31,34 @@ jobs:
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 }}", "tag_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

Comments
 (0)