-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: deploy Renovate-style JSON to GitHub Pages
* On each release, generate a set of JSON files in a directory named after the release tag. * A directory named latest will track the latest tagged release
- Loading branch information
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Check if the jq binary exists | ||
if ! [ -x "$(command -v jq)" ]; then | ||
echo "Error: 'jq' binary not found or not executable" >&2 | ||
exit 1 | ||
fi | ||
|
||
readonly OUTPUT_DIR="${OUTPUT_DIR:-public}" | ||
|
||
process_repo() { | ||
# For each defined package, output a list of its versions to a file <package>.json in the output directory | ||
echo "$1" | jq -r '.local.repo | to_entries[] | "\(.key).json"' | while read -r filename; do | ||
echo "$1" | jq --arg pkg "${filename%.json}" \ | ||
'{"releases": [ .local.repo[$pkg] | keys[] | {version: .} ]}' > "$OUTPUT_DIR/$filename" | ||
done | ||
} | ||
|
||
repo_as_json=$(cat) | ||
|
||
if ! echo "$repo_as_json" | jq empty 2>/dev/null; then | ||
echo "Error: Valid JSON is required" >&2 | ||
exit 1 | ||
else | ||
if [ ! -d "$OUTPUT_DIR" ]; then | ||
mkdir -p "$OUTPUT_DIR" | ||
fi | ||
process_repo "$repo_as_json" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,8 +140,38 @@ jobs: | |
ignore: Collect results | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
- uses: codfish/semantic-release-action@b621d34fabe0940f031e89b6ebfea28322892a10 # v3.5.0 | ||
with: | ||
sparse-checkout: | | ||
.cicd/ | ||
.releaserc.cjs | ||
- id: sem-rel | ||
uses: codfish/semantic-release-action@b621d34fabe0940f031e89b6ebfea28322892a10 # v3.5.0 | ||
with: | ||
additional-packages: [email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/[email protected] | ||
if: runner.debug || fromJSON(steps.sem-rel.outputs.new-release-published) | ||
- name: Transform dumped repo data to Renovate-style JSON | ||
if: runner.debug || fromJSON(steps.sem-rel.outputs.new-release-published) | ||
run: | | ||
if [ -f "$REPO_JSON_DIR/$REPO_JSON_FILE" ]; then | ||
.cicd/transform-json < "$REPO_JSON_DIR/$REPO_JSON_FILE" | ||
echo "::group::Display resulting directory structure" | ||
ls --almost-all --recursive --ignore node_modules --ignore .git | ||
echo "::endgroup::" | ||
fi | ||
- uses: peaceiris/[email protected] | ||
if: fromJSON(steps.sem-rel.outputs.new-release-published) | ||
with: | ||
commit_message: | | ||
deploy: ${{ steps.sem-rel.outputs.git-tag }} | ||
destination_dir: ${{ steps.sem-rel.outputs.git-tag }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: peaceiris/[email protected] | ||
if: fromJSON(steps.sem-rel.outputs.new-release-published) | ||
with: | ||
commit_message: | | ||
deploy: ${{ steps.sem-rel.outputs.git-tag }} on ${{ steps.sem-rel.outputs.channel }} | ||
destination_dir: ${{ steps.sem-rel.outputs.channel }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,8 @@ repos: | |
- id: biome-check | ||
name: Check JavaScript with biome | ||
additional_dependencies: ["@biomejs/[email protected]"] | ||
- repo: https://github.com/shellcheck-py/shellcheck-py | ||
rev: v0.10.0.1 | ||
hooks: | ||
- id: shellcheck | ||
name: Check shell scripts with shellcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters