Files
anki/tools/github-action-version-to-hash.sh
Christos Longros 2d88e386dc build: portability fixes for FreeBSD (#5300)
Two build fixes found while getting the build working on FreeBSD. 

1. **Remove hardcoded `#!/bin/bash` paths and use /usr/bin/env instead
/**
2. **env_remove("YARN_BINARY")**

Tested on FreeBSD 16.0-CURRENT amd64.

A second series adds FreeBSD support with `platform` variants,
environment overrides, PyQt6 handling and docs.

Closes #5301
2026-08-11 13:13:56 +03:00

25 lines
891 B
Bash
Executable File

#!/usr/bin/env bash
# Replace version tags with commit hashes in github actions workflows
# Example: "uses: actions/checkout@v4"
# -> "uses: actions/checkout@11bd...683 #v4"
shopt -s globstar
for workflow in .github/**/*.yml; do
grep -E "uses:[[:space:]]+[A-Za-z0-9._-]+/[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*@v[0-9]+" "$workflow" |
while read -r line; do
action=$(echo "$line" | sed -E 's/.*uses:[[:space:]]+([^[:space:]#]+)@v[0-9]+.*/\1/')
repo=$(echo "$action" | cut -d/ -f1,2)
tag=$(echo "$line" | sed -E 's/.*@(v[0-9]+).*/\1/')
commit_hash=$(git ls-remote "https://github.com/$repo.git" "refs/tags/$tag" | cut -f1)
if [ -n "$commit_hash" ]; then
sed -i.bak -E \
"s|(uses:[[:space:]]+$action@)$tag|\1$commit_hash #$tag|g" \
"$workflow"
rm -f "$workflow.bak"
fi
done
done