fix: wrapped threads around callbacks so the components wont hang #34
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: Build and Release | |
# Trigger on push to main branch | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write # Ensure that the workflow has write permissions | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the code from the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Set up Node.js environment for npm | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22' | |
# Install npm dependencies | |
- name: Install dependencies | |
working-directory: ./web | |
run: npm install | |
# Build the project | |
- name: Build project | |
working-directory: ./web | |
run: npm run build | |
# Remove unnecessary files | |
- name: Clean up unnecessary files | |
run: | | |
rm -rf ./web/node_modules | |
rm -f ./web/package-lock.json | |
# Create a zip file of the repository contents | |
- name: Create zip file | |
run: | | |
ZIP_FILE="./${{ github.event.repository.name }}.zip" # Name the zip file according to the repo name | |
# Create the zip file with the contents of the repo, excluding unnecessary files | |
zip -r $ZIP_FILE . -x "*.git*" "node_modules/*" "zip_content/*" | |
echo "ZIP_FILE=$ZIP_FILE" >> $GITHUB_ENV # Set the ZIP_FILE path as an environment variable | |
# Delete all previous releases and their tags | |
- name: Delete all previous releases | |
run: | | |
# Fetch all releases and delete them | |
RELEASES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases) | |
# Loop through each release and delete it | |
for RELEASE in $(echo "$RELEASES" | jq -r '.[].id'); do | |
echo "Deleting release ID: $RELEASE" | |
curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE | |
done | |
# Delete all tags | |
TAGS=$(git tag) | |
for TAG in $TAGS; do | |
echo "Deleting tag: $TAG" | |
git push --delete origin $TAG | |
done | |
# Get the commit message for the release name | |
- name: Get commit message | |
id: get_commit_message | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
echo "Release name: $COMMIT_MESSAGE" | |
echo "RELEASE_NAME=$COMMIT_MESSAGE" >> $GITHUB_ENV | |
# Create a new release with tag "latest" | |
- name: Create a Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "latest" # Set tag name to "latest" | |
release_name: ${{ env.RELEASE_NAME }} # Use the commit message as the release name | |
body: | | |
Automatically generated release based on the push | |
draft: false | |
prerelease: false | |
# Upload the zip file to the release | |
- name: Upload Build Artifacts to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.ZIP_FILE }} # Use the environment variable for the asset path | |
asset_name: ${{ github.event.repository.name }}.zip # Set asset name to the repository name | |
asset_content_type: application/zip |