cron-release #107
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: 'cron-release' | |
on: | |
# FIXME: manual run | |
workflow_dispatch: | |
# run daily, 3:00 UTC | |
schedule: | |
- cron: '56 2 * * *' | |
jobs: | |
pr-checks: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: 'Checkout pulp-ui (main)' | |
uses: actions/checkout@v4 | |
with: | |
ref: 'main' | |
fetch-depth: 128 | |
- name: 'Skip if no real changes since last npm version update' | |
run: | | |
LAST=`git blame package.json | grep '"version":' | awk '{ print $1 }'` | |
if git diff --exit-code "$LAST" -- src/ package.json; then | |
false | |
else | |
true | |
fi | |
- name: 'Install node 20' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: 'Install python 3.13' | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: 'Install moreutils' | |
run: | | |
sudo apt-get -y install moreutils | |
# FIXME: reuse pr-checks.yml? | |
- name: 'Checks' | |
run: | | |
# fail if npm install had to change package-lock.json | |
npm install | |
git diff --exit-code package-lock.json | |
# dependencies | |
npm run lint-setup | |
# run linters | |
npm run lint | |
# run test | |
npm run test | |
- name: 'Set PULP_UI_VERSION' | |
run: | | |
# used in npm run build | |
echo "PULP_UI_VERSION=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: 'git config' | |
run: | | |
git config --local user.name "cron-release workflow" | |
git config --local user.email "pulp-ui+cron-release@example.com" | |
- name: 'Update gettext' | |
run: | | |
npm run gettext:extract | |
npm run gettext:compile | |
git add locale/ | |
git commit -m "locale update on $(date --iso=d)" || true | |
- name: 'Increment npm version, version tag' | |
run: 'npm version patch' | |
- name: 'Set NPM_VERSION, TARBALL' | |
run: | | |
echo "NPM_VERSION=$(jq -r .version < package.json)" >> $GITHUB_ENV | |
echo "TARBALL=pulp-ui-$(date --iso=d).tar.gz" >> $GITHUB_ENV | |
- name: 'Build UI dist/' | |
run: 'npm run build' | |
- name: 'Build a tarball' | |
run: | | |
tar -C dist/ -czvf "$TARBALL" . | |
- name: 'Push, push tags' | |
run: | | |
git push | |
git push -f --tags | |
- name: 'Release' | |
run: | | |
gh release create v"$NPM_VERSION" --title "pulp-ui $NPM_VERSION $(date --iso=d)" --generate-notes | |
gh release upload v"$NPM_VERSION" "$TARBALL" --clobber | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Update CHANGES.md' | |
run: | | |
( | |
curl -s https://api.github.com/repos/pulp/pulp-ui/releases/latest | \ | |
jq -r '.name,"",.body' | \ | |
sed -e 's/^## /### /' -e 's/^pulp-ui \(.*\) \(.*\)/## \1 (\2) {: #\1 }/' | \ | |
grep -v '^\* Bump .* by @dependabot in ' | \ | |
sed -e 's/^\(\* .*\) by @[a-zA-Z][-a-zA-Z0-9_]\+ in https:\/\/github.com\/pulp\/pulp-ui\/pull\/\([0-9]\+\)$/\1 [#\2](https:\/\/github.com\/pulp\/pulp-ui\/pull\/\2)/' | |
echo | |
echo '---' | |
echo | |
cat CHANGES.md | |
) | sponge CHANGES.md | |
git add CHANGES.md | |
git commit -m "changelog update for $NPM_VERSION" | |
git push |