Skip to content
name: Update from Upstream
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
push:
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: fetch latest release tag from upstream repo
id: fetch_release
uses: actions/github-script@v7
with:
script: |
const owner = 'MixinNetwork';
const repo = 'flutter-app';
const { data: latestRelease } = await github.rest.repos.getLatestRelease({owner, repo});
core.setOutput('tag_name', latestRelease.tag_name);
- name: check has upgrade
id: check_upgrade
run: |
current_version=$(grep -oP "(?<=https://github.com/MixinNetwork/flutter-app/releases/download/).*(?=/mixin_desktop_linux_amd64_portable.tar.gz)" one.mixin.messenger.yml)
echo "current version: $current_version, remote version: ${{ steps.fetch_release.outputs.tag_name }}"
if [ "$current_version" != "${{ steps.fetch_release.outputs.tag_name }}" ]; then
echo "new version available"
echo "new_version=${{ steps.fetch_release.outputs.tag_name }}" >> $GITHUB_ENV
echo "current_version=$current_version" >> $GITHUB_ENV
wget https://github.com/MixinNetwork/flutter-app/releases/download/v1.9.0/mixin_desktop_linux_amd64_portable.tar.gz -O mixin_desktop_linux_amd64_portable.tar.gz
new_version_sha256=$(sha256sum mixin_desktop_linux_amd64_portable.tar.gz | cut -d' ' -f1)
echo "new_version_sha256=$new_version_sha256" >> $GITHUB_ENV
else
echo "no new version available"
exit 0
fi
- name: Update version
if: env.new_version
run: |
sed -i -e 's/${{ env.current_version }}/${{ env.new_version }}/g' one.mixin.messenger.yml
sed -i -e 's/sha256:.*/sha256: ${{ env.new_version_sha256 }}/g' one.mixin.messenger.yml
- name: Commit changes
if: env.new_version
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add one.mixin.messenger.yml
git commit -m "Update to version ${{ steps.fetch_release.outputs.tag_name }}"
git push origin HEAD:update-version-${{ steps.fetch_release.outputs.tag_name }}
# - name: Create Pull Request
# if: env.new_version
# uses: peter-evans/create-pull-request@v5
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# commit-message: Update to version ${{ steps.fetch_release.outputs.tag_name }}
# branch: update-version-${{ steps.fetch_release.outputs.tag_name }}
# title: Update to version ${{ steps.fetch_release.outputs.tag_name }}
# body: This PR updates the version to ${{ steps.fetch_release.outputs.tag_name }}.