@@ -11,24 +11,45 @@ jobs:
1111 build-release :
1212 runs-on : ubuntu-latest
1313 steps :
14+ - name : Check update
15+ env :
16+ UPSTREAM_REPO : " neovide/neovide" # upstream repo
17+ LOCAL_REPO : " ${{ github.repository }}"
18+ run : |
19+ get_github_latest_version() {
20+ curl -sw "%{redirect_url}" "https://github.com/$1/releases/latest" |
21+ sed -n 's|.*/releases/tag/[^0-9]*\([^_]*\).*|\1|p'
22+ }
23+ # get local version
24+ LOCAL_VERSION=$(get_github_latest_version "$LOCAL_REPO")
25+ if [ -z "$LOCAL_VERSION" ]; then
26+ LOCAL_VERSION="0"
27+ fi
28+ # get upstream version
29+ UPSTREAM_VERSION=$(get_github_latest_version "$UPSTREAM_REPO")
30+ # compare versions
31+ if [ -z "$UPSTREAM_VERSION" ]; then
32+ echo "Error: Can't get version from $UPSTREAM_REPO."
33+ echo "VERSION=0" >> $GITHUB_ENV
34+ elif [ "$LOCAL_VERSION" = "$UPSTREAM_VERSION" ]; then
35+ echo "No update. The version is ($UPSTREAM_VERSION)."
36+ echo "VERSION=0" >> $GITHUB_ENV
37+ else
38+ echo "Update to $UPSTREAM_VERSION from $LOCAL_VERSION."
39+ echo "VERSION=$UPSTREAM_VERSION" >> $GITHUB_ENV
40+ fi
41+
1442 - name : Checkout
43+ if : ${{ env.VERSION != '0' }}
1544 uses : actions/checkout@v4
1645
17- - name : Get Version
18- run : |
19- ./check.sh
20- echo "tag=$(cat tag)" >> $GITHUB_ENV
21-
2246 - name : Build
23- if : ${{ env.tag != '0' }}
24- run : ./build.sh
47+ if : ${{ env.VERSION != '0' }}
48+ run : ./build.sh $VERSION
2549
2650 - name : Release
2751 uses : softprops/action-gh-release@v2
28- if : ${{ env.tag != '0' }}
52+ if : ${{ env.VERSION != '0' }}
2953 with :
30- tag_name : v${{ env.tag }}
31- files : |
32- *.deb
33- Packages
34- Release
54+ tag_name : v${{ env.VERSION }}
55+ files : output/*
0 commit comments