Sync repo and generate tags #22
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: Sync repo and generate tags | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '45 */6 * * *' # At minute 45 past every 6th hour. | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Setup bun | |
uses: oven-sh/setup-bun@v2 | |
- name: Create release | |
run: | | |
git config --global user.name github-actions | |
git config --global user.email [email protected] | |
git clone https://github.com/LemmyNet/lemmy-js-client.git | |
git -C ./lemmy-js-client fetch --tags | |
LATEST=$(git -C ./lemmy-js-client for-each-ref refs/tags --sort=-committerdate --format='%(refname:short)' --count=1) | |
bun install | |
LEMMY_VERSION=$LATEST bun run generate | |
git add . | |
git commit -m "Sync OpenAPI spec" || true | |
git push | |
TAGS=$(git -C ./lemmy-js-client for-each-ref refs/tags --sort=-committerdate --format='%(refname:short)' --count=10) | |
for tag in $TAGS; do | |
if [ $(git tag -l $tag) ]; then | |
echo "Tag $tag already exists" | |
continue | |
fi | |
git checkout -b $tag | |
git -C ./lemmy-js-client checkout $tag | |
bun install | |
LEMMY_VERSION=$tag bun run generate | |
git add . | |
git commit -m "Release $tag" | |
git tag $tag | |
git push origin tag $tag | |
git checkout main | |
done |