Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Sep 17, 2024
2 parents 34cd534 + 0c93cbd commit 43a1b53
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 25 deletions.
35 changes: 21 additions & 14 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,30 @@ jobs:
- name: Authenticate GitHub CLI
run: gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }}

- name: Check if release exists
id: check_release
- name: Delete existing release and tag if found
run: |
if gh release view v${{ env.VERSION }} > /dev/null 2>&1; then
echo "Release exists"
echo "release_exists=true" >> $GITHUB_ENV
VERSION="v${{ env.VERSION }}"
if gh release view "$VERSION" > /dev/null 2>&1; then
echo "Release $VERSION exists. Deleting release..."
gh release delete "$VERSION" --yes
else
echo "Release does not exist"
echo "release_exists=false" >> $GITHUB_ENV
echo "Release $VERSION does not exist."
fi
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION exists locally. Deleting tag..."
git tag -d "$VERSION" || true
else
echo "Tag $VERSION does not exist locally."
fi
if git ls-remote --tags origin | grep "refs/tags/$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION exists on remote. Deleting remote tag..."
git push origin :refs/tags/"$VERSION" || true
else
echo "Tag $VERSION does not exist on remote."
fi
- name: Delete existing release and tag if found
if: env.release_exists == 'true'
run: |
gh release delete v${{ env.VERSION }} --yes
git tag -d v${{ env.VERSION }}
git push origin :refs/tags/v${{ env.VERSION }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
41 changes: 30 additions & 11 deletions .github/workflows/web-assembly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,43 @@ jobs:
git clone https://github.com/SalamLang/Salam-Editor.git
cp ./src/salam-wa.js ./Salam-Editor/
cp ./src/salam-wa.wasm ./Salam-Editor/
cd Salam-Editor
sudo chown www-data:www-data *
git config user.name "Max Base"
git config user.email "$EMAIL"
- name: Check for changes in WebAssembly files
- name: Calculate checksums of original files
id: original_checksums
run: |
cd src
ls -l salam-wa.js salam-wa.wasm
sha256sum salam-wa.js > js-checksum.txt || echo "Error calculating checksum for salam-wa.js"
sha256sum salam-wa.wasm > wasm-checksum.txt || echo "Error calculating checksum for salam-wa.wasm"
echo "JS_CHECKSUM=$(cat js-checksum.txt | awk '{ print $1 }')" >> $GITHUB_ENV
echo "WASM_CHECKSUM=$(cat wasm-checksum.txt | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Calculate checksums of new files in Salam-Editor
id: new_checksums
run: |
cd Salam-Editor
ls -l salam-wa.js salam-wa.wasm
sha256sum salam-wa.js > js-checksum-editor.txt || echo "Error calculating checksum for salam-wa.js"
sha256sum salam-wa.wasm > wasm-checksum-editor.txt || echo "Error calculating checksum for salam-wa.wasm"
echo "JS_CHECKSUM_EDITOR=$(cat js-checksum-editor.txt | awk '{ print $1 }')" >> $GITHUB_ENV
echo "WASM_CHECKSUM_EDITOR=$(cat wasm-checksum-editor.txt | awk '{ print $1 }')" >> $GITHUB_ENV
git diff --exit-code salam-wa.js salam-wa.wasm
continue-on-error: true

- name: Commit and push if changes detected
if: ${{ steps.check-for-changes.outcome == 'failure' }}
- name: Commit and push changes if needed
if: ${{ env.JS_CHECKSUM != env.JS_CHECKSUM_EDITOR || env.WASM_CHECKSUM != env.WASM_CHECKSUM_EDITOR }}
run: |
cp ./src/salam-wa.js ./Salam-Editor/
cp ./src/salam-wa.wasm ./Salam-Editor/
cd Salam-Editor
sudo chown -R www-data:www-data *
git add salam-wa.js salam-wa.wasm
git commit -m "Release: Update WebAssembly files"
git push https://x-access-token:${{ secrets.USER_TOKEN }}@github.com/SalamLang/Salam-Editor.git

0 comments on commit 43a1b53

Please sign in to comment.