-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (64 loc) · 3.27 KB
/
update-from-upstream.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Update from Upstream
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
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/${{ steps.fetch_release.outputs.tag_name }}/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
CURRENT_DATE=$(date '+%Y-%-m-%-d')
sed -i '/<releases>/a\ <release version="${{ env.new_version }}" date="xxxx-x-xx" />' one.mixin.messenger.metainfo.xml
sed -i "/<releases>/a\ <release version=\"${{ env.new_version }}\" date=\"$CURRENT_DATE\" />" one.mixin.messenger.metainfo.xml
- 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 }} -f
- 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 }}.