Skip to content

Commit 182dcf2

Browse files
committed
mv check to CI; add remote trigger
1 parent b6a5f36 commit 182dcf2

4 files changed

Lines changed: 74 additions & 52 deletions

File tree

.github/workflows/build.yaml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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/*
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: build and release by remote trigger
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version of Upstream Release'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build-release-by-remote-trigger:
13+
runs-on: ubuntu-latest
14+
env:
15+
VERSION: ${{ inputs.version }}
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Build
21+
run: ./build.sh $VERSION
22+
23+
- name: Release
24+
uses: softprops/action-gh-release@v2
25+
with:
26+
tag_name: v${{ env.VERSION }}
27+
files: output/*

build.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@
33
PACKAGE="neovide"
44
REPO="neovide/neovide"
55

6-
VERSION="$(cat tag)"
6+
# Processing again to avoid errors of remote incoming
7+
VERSION=$(echo $1 | sed -n 's|[^0-9]*\([^_]*\).*|\1|p')
78

89
ARCH="amd64"
910
AMD64_FILENAME="neovide-linux-x86_64.tar.gz"
1011
ARM64_FILENAME=""
11-
12-
get_url_by_arch() {
13-
case $1 in
14-
"amd64") echo "https://github.com/$REPO/releases/latest/download/$AMD64_FILENAME" ;;
15-
"arm64") echo "https://github.com/$REPO/releases/latest/download/$ARM64_FILENAME" ;;
16-
esac
17-
}
18-
1912
build() {
2013
# Prepare
2114
BASE_DIR="$PACKAGE"_"$VERSION"-1_"$1"
@@ -31,14 +24,24 @@ build() {
3124
mv "$PACKAGE" "$BASE_DIR/usr/bin/$PACKAGE"
3225
chmod 755 "$BASE_DIR/usr/bin/$PACKAGE"
3326
# Build
34-
dpkg-deb --build --root-owner-group -Z xz "$BASE_DIR"
27+
dpkg-deb -b --root-owner-group -Z xz "$BASE_DIR" output
3528
}
3629

30+
get_url_by_arch() {
31+
case $1 in
32+
"amd64") echo "https://github.com/$REPO/releases/latest/download/$AMD64_FILENAME" ;;
33+
"arm64") echo "https://github.com/$REPO/releases/latest/download/$ARM64_FILENAME" ;;
34+
esac
35+
}
36+
37+
mkdir output
38+
3739
for i in $ARCH; do
3840
echo "Building $i package..."
3941
build "$i"
4042
done
4143

4244
# Create repo files
45+
cd output
4346
apt-ftparchive packages . > Packages
4447
apt-ftparchive release . > Release

check.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)