Skip to content

Develop

Develop #26

Workflow file for this run

name: Update files
on:
pull_request:
types:
- closed
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
update_files:
if: github.event.pull_request.merged == true
name: Update files job
runs-on: [ self-hosted, macOS ]
outputs:
version: ${{ steps.read_version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Read version from pubspec.yml
working-directory: zstandard_platform_interface
id: read_version
run: |
VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Pre check tag
id: pre_check_tag
run: |
# Checks if the tag already exists in the remote repository
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Error: Tag v${{ env.VERSION }} already exists."
exit 1
fi
# Check if the version was found
if [ -z "${{ env.VERSION }}" ]; then
echo "Error: No version found in pubspec.yml"
exit 1
fi
- name: Copy CHANGELOG.md
run: |
cp CHANGELOG.md "zstandard_platform_interface/CHANGELOG.md"
cp CHANGELOG.md "zstandard_android/CHANGELOG.md"
cp CHANGELOG.md "zstandard_ios/CHANGELOG.md"
cp CHANGELOG.md "zstandard_macos/CHANGELOG.md"
cp CHANGELOG.md "zstandard_windows/CHANGELOG.md"
cp CHANGELOG.md "zstandard_linux/CHANGELOG.md"
cp CHANGELOG.md "zstandard_web/CHANGELOG.md"
cp CHANGELOG.md "zstandard_cli/CHANGELOG.md"
cp CHANGELOG.md "zstandard/CHANGELOG.md"
- name: Update version in zstandard_android pubspec.yaml
working-directory: zstandard_android
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_ios pubspec.yaml
working-directory: zstandard_ios
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_macos pubspec.yaml
working-directory: zstandard_macos
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_linux pubspec.yaml
working-directory: zstandard_linux
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_windows pubspec.yaml
working-directory: zstandard_windows
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_web pubspec.yaml
working-directory: zstandard_web
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard pubspec.yaml
working-directory: zstandard
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_android: .*/ zstandard_android: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_ios: .*/ zstandard_ios: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_web: .*/ zstandard_web: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_macos: .*/ zstandard_macos: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_windows: .*/ zstandard_windows: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_linux: .*/ zstandard_linux: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_cli pubspec.yaml
working-directory: zstandard_cli
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
- name: Git pull --no-ff
run: |
git pull --no-ff origin master
- name: Commit and Push version updates
uses: EndBug/add-and-commit@v9
with:
add: '.'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Bump dependencies version to ${{ env.VERSION }}'
- name: Handle job completion
if: always()
run: |
if [ "${{ job.status }}" == "failure" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🔴 Update files Failed" \
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \
--url "https://github.com/landamessenger/object/actions/workflows/update_files.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
elif [ "${{ job.status }}" == "cancelled" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟠 Update files Canceled" \
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \
--url "https://github.com/landamessenger/object/actions/workflows/update_files.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
else
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟢 Update files Passed" \
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \
--url "https://github.com/landamessenger/object/actions/workflows/update_files.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
fi
cli_build_macos_precompiled_libs:
name: macOS precompiled libraries
runs-on: [ self-hosted, macOS ]
needs: [update_files]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Read version from pubspec.yml
working-directory: zstandard_platform_interface
id: read_version
run: |
VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download source files from facebook/zstd
run: |
cd zstandard_cli
git clone https://github.com/facebook/zstd.git
mkdir src
mv zstd/lib/* src/
rm -rf zstd/
- name: List files in zstd/lib to verify
run: cd zstandard_cli && ls -R src
- name: Compile x86-x64 macos lib
run: |
cd zstandard_cli/builders/macos_intel
mkdir build && cd build
cmake ..
cmake --build . --config Release
mv libzstandard_macos.dylib ../../../lib/src/bin/libzstandard_macos_intel.dylib
cd ..
rm -rf build
- name: Compile arm64 macos lib
run: |
cd zstandard_cli/builders/macos_arm
mkdir build && cd build
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 ..
cmake --build . --config Release
mv libzstandard_macos.dylib ../../../lib/src/bin/libzstandard_macos_arm.dylib
cd ..
rm -rf build
- name: Join libs
run: |
cd zstandard_cli/lib/src/bin
lipo -create -output libzstandard_macos.dylib libzstandard_macos_intel.dylib libzstandard_macos_arm.dylib
rm libzstandard_macos_arm.dylib
rm libzstandard_macos_intel.dylib
- name: Verify libs
run: |
cd zstandard_cli/lib/src/bin
lipo -info libzstandard_macos.dylib
- name: Git pull --no-ff
run: |
git pull --no-ff origin master
- name: Commit and Push Library
uses: EndBug/add-and-commit@v9
with:
add: './zstandard_cli/lib/src/bin/libzstandard_macos.dylib'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Add precompiled macOS libraries for x86_64 and arm64'
cli_build_linux_precompiled_libs:
name: Linux precompiled libraries
runs-on: [ self-hosted, Linux ]
needs: [ update_files ]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Read version from pubspec.yml
working-directory: zstandard_platform_interface
id: read_version
run: |
VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download source files from facebook/zstd
run: |
cd zstandard_cli
git clone https://github.com/facebook/zstd.git
mkdir src
mv zstd/lib/* src/
rm -rf zstd/
- name: List files in zstd/lib to verify
run: cd zstandard_cli && ls -R src
- name: Compile x86_64 Linux lib
run: |
cd zstandard_cli/builders/linux_x64
mkdir build && cd build
cmake ..
cmake --build . --config Release
mv libzstandard_linux.so ../../../lib/src/bin/libzstandard_linux_x64.so
cd ..
rm -rf build
- name: Compile arm64 Linux lib
run: |
cd zstandard_cli/builders/linux_arm
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../arm64-toolchain.cmake ..
cmake --build . --config Release
mv libzstandard_linux.so ../../../lib/src/bin/libzstandard_linux_arm64.so
cd ..
rm -rf build
- name: Verify Linux libs
run: |
cd zstandard_cli/lib/src/bin
file libzstandard_linux_x64.so
file libzstandard_linux_arm64.so
- name: Git pull --no-ff
run: |
git pull --no-ff origin master
- name: Commit and Push Library
uses: EndBug/add-and-commit@v9
with:
add: './zstandard_cli/lib/src/bin/'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Add precompiled Linux libraries for x86_64 and arm64'
cli_build_windows_precompiled_libs:
name: Windows precompiled libraries
runs-on: [ self-hosted, Windows ]
needs: [ update_files ]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
shell: cmd
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
shell: cmd
run: npm install -g @landamessenger/landa-messenger-api
- name: Download source files from facebook/zstd
shell: cmd
run: |
cd zstandard_cli
git clone https://github.com/facebook/zstd.git
mkdir src
xcopy zstd\lib src\ /E /I
rmdir /S /Q zstd
- name: List files in zstd/lib to verify
shell: cmd
run: dir zstandard_cli\src /S
- name: Compile x86_64 Windows lib
shell: cmd
run: |
cd zstandard_cli/builders/windows_x64
mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A x64 ..
cmake --build . --config Release
cd Release
move zstandard_windows.dll ..\..\..\..\lib\src\bin\zstandard_windows_x64.dll
cd ..
cd ..
rmdir /S /Q build
- name: Compile arm64 Windows lib
shell: cmd
run: |
cd zstandard_cli/builders/windows_arm
mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A ARM64 ..
cmake --build . --config Release
cd Release
move zstandard_windows.dll ..\..\..\..\lib\src\bin\zstandard_windows_arm64.dll
cd ..
cd ..
rmdir /S /Q build
- name: Verify Windows libs architecture
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64
dumpbin /headers zstandard_cli/lib/src/bin/zstandard_windows_x64.dll | findstr /c:"machine"
dumpbin /headers zstandard_cli/lib/src/bin/zstandard_windows_arm64.dll | findstr /c:"machine"
- name: Git pull --no-ff
shell: cmd
run: |
git pull --no-ff origin master
- name: Commit and Push Library
uses: EndBug/add-and-commit@v9
with:
add: './zstandard_cli/lib/src/bin/'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Add precompiled Windows libraries for x86_64 and arm64'
tag_version:
name: Tag version and create release
runs-on: [ self-hosted, macOS ]
needs: [update_files, cli_build_windows_precompiled_libs, cli_build_linux_precompiled_libs, cli_build_macos_precompiled_libs]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Create tag
id: create_tag
run: |
# Check if the tag already exists in the remote repository
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Tag v${{needs.update_files.outputs.version}} already exists."
else
# Create and push the new tag
git tag "v${{needs.update_files.outputs.version}}"
git push origin "v${{needs.update_files.outputs.version}}"
fi
- name: Create release
if: ${{ steps.create_tag.outcome == 'success' }}
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{needs.update_files.outputs.version}}"
name: "${{ github.event.pull_request.title }}"
body: "${{ github.event.pull_request.body }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Handle job completion
if: always()
run: |
if [ "${{ job.status }}" == "failure" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🔴 Creation Tag Failed" \
--body "${{ github.repository }}: Tag v${{needs.update_files.outputs.version}}" \
--url "https://github.com/landamessenger/zstandard/actions/workflows/tag_version_and_publish.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
elif [ "${{ job.status }}" == "cancelled" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟠 Creation Tag Canceled" \
--body "${{ github.repository }}: Tag v${{needs.update_files.outputs.version}}" \
--url "https://github.com/landamessenger/zstandard/actions/workflows/tag_version_and_publish.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
else
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟢 Creation Tag Passed" \
--body "${{ github.repository }}: Tag v${{needs.update_files.outputs.version}}" \
--url "https://github.com/landamessenger/zstandard/actions/workflows/tag_version_and_publish.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
fi