Bump Version #249
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
name: Bump Version | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{ secrets.SSH_KEY }} | |
fetch-depth: 0 | |
- | |
name: Setup Node.js with version 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- | |
name: Get Node.js versions | |
run: | | |
echo NODE_VERSIONS=$( | |
curl -fsSL https://raw.githubusercontent.com/nodejs/Release/main/schedule.json | | |
jq -r ". | to_entries[] | select(.value.lts and .value.start <= \"$(date +%Y-%m-%d)\" and .value.end >= \"$(date +%Y-%m-%d)\") | .key | sub(\"v\";\"\")" | |
) | tee /dev/stderr >> $GITHUB_ENV | |
- | |
name: Get Redoc CLI versions | |
run: | | |
echo git tag --sort -authordate | tee /dev/stderr | source /dev/stdin | |
echo PACKAGE_VERSIONS=$( | |
npm view -s redoc-cli@\>$(git tag --sort -authordate | grep "node$(echo $NODE_VERSIONS | cut -d\ -f1)\$" | head -n1 | sed -e "s/-node[0-9]\+//") version | sed -e "s/redoc-cli@.* '\(.*\)'/\\1/" | |
) | tee /dev/stderr >> $GITHUB_ENV | |
- | |
name: Bump | |
run: | | |
test -z "$PACKAGE_VERSIONS" && exit 0 || : | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
echo git checkout -b node$(echo $NODE_VERSIONS | cut -d\ -f1) $(git tag --sort -authordate | grep "node$(echo $NODE_VERSIONS | cut -d\ -f1)$" | head -n1) | tee /dev/stderr | source /dev/stdin | |
if test $(git diff --numstat main | wc -l) -gt 0 | |
then | |
echo git reset --hard HEAD~ | tee /dev/stderr | source /dev/stdin | |
echo git merge --no-ff --no-commit main | tee /dev/stderr | source /dev/stdin | |
echo git checkout HEAD -- Dockerfile | tee /dev/stderr | source /dev/stdin | |
echo git commit -m \"Merge branch 'main' to $(git rev-parse --abbrev-ref @)\" | tee /dev/stderr | source /dev/stdin | |
else | |
echo git reset --hard HEAD~ | tee /dev/stderr | source /dev/stdin | |
fi | |
for package in $PACKAGE_VERSIONS | |
do | |
echo git checkout node$(echo $NODE_VERSIONS | cut -d\ -f1) | tee /dev/stderr | source /dev/stdin | |
echo sed -i -e \"s/redoc-cli@.*/redoc-cli@$package/\" Dockerfile | tee /dev/stderr | source /dev/stdin | |
echo git commit -am \"Bump redoc-cli to ${package##redoc-cli@}\" | tee /dev/stderr | source /dev/stdin | |
echo git tag ${package##redoc-cli@}-node$(echo $NODE_VERSIONS | cut -d\ -f1) | tee /dev/stderr | source /dev/stdin | |
echo git push origin $(git describe --tags) | tee /dev/stderr | source /dev/stdin | |
sleep 60 | |
for node in $(echo $NODE_VERSIONS | cut -d\ -f2-) | |
do | |
if test $(git branch --list node$node | wc -l) -gt 0 | |
then | |
if git rev-parse $(git describe --tags | sed -e "s/[0-9]\+\$/$node/") >/dev/null 2>&1 | |
then | |
echo git branch node$node $(git describe --tags | sed -e "s/[0-9]\+\$/$node/") | tee /dev/stderr | source /dev/stdin | |
else | |
echo sed -i -e \"s/node:[0-9]\+-slim/node:$node-slim/\" Dockerfile | tee /dev/stderr | source /dev/stdin | |
echo git commit -am \"Bump Node.js to $node\" | tee /dev/stderr | source /dev/stdin | |
echo git checkout -b node$node | tee /dev/stderr | source /dev/stdin | |
echo git checkout node$(echo $NODE_VERSIONS | cut -d\ -f1) | tee /dev/stderr | source /dev/stdin | |
fi | |
else | |
echo git checkout node$node | tee /dev/stderr | source /dev/stdin | |
fi | |
previous=$(echo $NODE_VERSIONS | sed -e "s/\([0-9]\+ \)*\([0-9]\+\) $node.*/\2/") | |
echo git merge --no-ff --no-commit node$previous | tee /dev/stderr | source /dev/stdin | |
echo sed -i -e \"s/node:[0-9]\+-slim/node:$node-slim/\" Dockerfile | tee /dev/stderr | source /dev/stdin | |
echo git commit --all --reuse-message node$previous | tee /dev/stderr | source /dev/stdin | |
echo git tag ${package##redoc-cli@}-node$node | tee /dev/stderr | source /dev/stdin | |
echo git push origin $(git describe --tags) | tee /dev/stderr | source /dev/stdin | |
sleep 60 | |
done | |
done | |
echo git checkout main | tee /dev/stderr | source /dev/stdin | |
echo git merge --ff node$(echo $NODE_VERSIONS | rev | cut -d\ -f1 | rev) | tee /dev/stderr | source /dev/stdin | |
echo git push origin main | tee /dev/stderr | source /dev/stdin |