2021-09-11 09:37:29 +00:00
|
|
|
name: Update Repository
|
|
|
|
|
|
|
|
# Controls when the workflow will run
|
|
|
|
on:
|
2023-02-17 14:13:44 +00:00
|
|
|
#push:
|
2021-09-11 11:38:55 +00:00
|
|
|
# If the configuration has changed, this ensures we apply updates.
|
2023-02-17 14:13:44 +00:00
|
|
|
#branches: [ main ]
|
2021-09-11 09:37:29 +00:00
|
|
|
|
2021-09-11 11:38:55 +00:00
|
|
|
schedule:
|
|
|
|
# Upstream releases around once per month, so twice a week should be fine.
|
|
|
|
- cron: '23 14 * * mon,thu'
|
2021-09-11 09:37:29 +00:00
|
|
|
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
2023-03-20 16:33:34 +00:00
|
|
|
check-upstream:
|
|
|
|
name: Check for a new releases upstream
|
2023-05-12 13:54:06 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-09-11 09:37:29 +00:00
|
|
|
|
2023-02-17 15:01:55 +00:00
|
|
|
outputs:
|
2023-03-20 16:33:34 +00:00
|
|
|
innernet_release: ${{ steps.check-latest-release.outputs.innernet_release }}
|
2023-05-01 07:25:15 +00:00
|
|
|
innernet_version: ${{ steps.check-latest-release.outputs.innernet_version }}
|
2023-03-20 16:33:34 +00:00
|
|
|
tarball_url: ${{ steps.check-latest-release.outputs.tarball_url }}
|
|
|
|
new_release_exists: ${{ steps.check-repo-release.outputs.new_release_exists }}
|
2023-05-01 07:25:15 +00:00
|
|
|
|
2021-09-11 09:37:29 +00:00
|
|
|
steps:
|
2023-02-17 14:13:44 +00:00
|
|
|
- name: Install Distro Dependencies
|
2023-03-20 16:33:34 +00:00
|
|
|
run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes jq liblzma-dev reprepro
|
2023-02-17 14:13:44 +00:00
|
|
|
|
2023-05-01 07:25:15 +00:00
|
|
|
- name: Set Ubuntu Release Name
|
|
|
|
id: set-ubuntu-release-name
|
|
|
|
run: |
|
|
|
|
echo "ubuntu_release=$(lsb_release --short --codename)" >>"$GITHUB_OUTPUT"
|
|
|
|
|
2023-03-20 16:33:34 +00:00
|
|
|
- name: Check Latest Release
|
|
|
|
id: check-latest-release
|
2023-02-17 14:13:44 +00:00
|
|
|
run: |
|
|
|
|
wget -O- \
|
|
|
|
-H'Accept: application/json' \
|
2023-02-17 14:15:02 +00:00
|
|
|
"https://api.github.com/repos/tonarino/innernet/releases/latest" \
|
2023-02-17 14:13:44 +00:00
|
|
|
| jq -r '(.name + " " + .tarball_url)' \
|
|
|
|
| (
|
|
|
|
read release tarball_url
|
|
|
|
echo "innernet_release=$release" >>"$GITHUB_OUTPUT"
|
2023-05-01 07:25:15 +00:00
|
|
|
echo "innernet_version=${release#v}" >>"$GITHUB_OUTPUT"
|
2023-03-20 16:33:34 +00:00
|
|
|
echo "tarball_url=$tarball_url" >>"$GITHUB_OUTPUT"
|
2023-03-20 16:59:36 +00:00
|
|
|
echo "Latest release: $release"
|
2023-02-17 14:13:44 +00:00
|
|
|
)
|
|
|
|
|
2023-03-20 16:37:50 +00:00
|
|
|
- name: Checkout
|
2023-05-12 13:21:21 +00:00
|
|
|
uses: actions/checkout@v3
|
2023-03-20 16:37:50 +00:00
|
|
|
with:
|
|
|
|
# See https://github.com/marketplace/actions/github-push
|
|
|
|
persist-credentials: false
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-03-20 16:33:34 +00:00
|
|
|
- name: Check Repo Release
|
|
|
|
id: check-repo-release
|
|
|
|
run: |
|
2023-05-12 13:54:06 +00:00
|
|
|
new_release_exists=
|
2023-05-12 13:58:59 +00:00
|
|
|
for ver_codename in ubuntu-22.04/jammy ubuntu-20.04/focal; do
|
2023-05-12 13:54:06 +00:00
|
|
|
ver=${ver_codename%/*}
|
|
|
|
codename=${ver_codename##*/}
|
|
|
|
# Note the leading v to match the Git tag.
|
|
|
|
indexed=v$(reprepro -b debian --list-format '${version}\n' listmatched "$codename" innernet)
|
|
|
|
upstream="${{ steps.check-latest-release.outputs.innernet_release }}-0ubuntu0~$codename"
|
|
|
|
echo "Repo release in $codename: $indexed"
|
|
|
|
if [ "x$indexed" != "x$upstream" ]; then
|
2023-05-12 14:08:56 +00:00
|
|
|
new_release_exists="${new_release_exists:+$new_release_exists,}\"$ver\""
|
2023-05-12 13:54:06 +00:00
|
|
|
fi
|
|
|
|
done
|
2023-05-12 14:08:56 +00:00
|
|
|
echo "new_release_exists=[$new_release_exists]" >>"$GITHUB_OUTPUT"
|
2023-05-01 07:25:15 +00:00
|
|
|
|
2023-03-20 16:54:26 +00:00
|
|
|
- name: Show Output
|
|
|
|
id: show-output
|
|
|
|
run: |
|
|
|
|
echo "## Job Outputs" >>"$GITHUB_STEP_SUMMARY"
|
2023-03-20 17:05:33 +00:00
|
|
|
echo "* \`innernet_release=${{ steps.check-latest-release.outputs.innernet_release }}\`" >>"$GITHUB_STEP_SUMMARY"
|
2023-05-01 07:25:15 +00:00
|
|
|
echo "* \`innernet_version=${{ steps.check-latest-release.outputs.innernet_version }}\`" >>"$GITHUB_STEP_SUMMARY"
|
2023-03-20 17:05:33 +00:00
|
|
|
echo "* \`new_release_exists=${{ steps.check-repo-release.outputs.new_release_exists }}\`" >>"$GITHUB_STEP_SUMMARY"
|
2023-03-20 16:33:34 +00:00
|
|
|
|
|
|
|
build-deb:
|
|
|
|
name: Build DEB Packages
|
|
|
|
needs: [check-upstream]
|
2023-05-15 15:19:44 +00:00
|
|
|
if: "matrix.os[0] != null"
|
2023-05-01 07:25:15 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-05-12 14:08:56 +00:00
|
|
|
os: ${{ fromJson(needs.check-upstream.outputs.new_release_exists) }}
|
2023-03-20 16:33:34 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Install Distro Dependencies
|
|
|
|
run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes dpkg-dev liblzma-dev
|
|
|
|
|
2023-05-12 14:25:01 +00:00
|
|
|
- name: Translate Codename
|
|
|
|
id: translate-codename
|
|
|
|
run: |
|
|
|
|
case "${{ matrix.os }}" in
|
2023-05-12 14:28:29 +00:00
|
|
|
ubuntu-22.04) codename=jammy ;;
|
|
|
|
ubuntu-20.04) codename=focal ;;
|
2023-05-12 14:25:01 +00:00
|
|
|
*)
|
|
|
|
echo "Unknown OS: ${{ matrix.os }}" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "codename=$codename" >>"$GITHUB_OUTPUT"
|
|
|
|
|
2023-03-20 16:33:34 +00:00
|
|
|
- name: Download Latest Release
|
|
|
|
id: download-release
|
|
|
|
run: |
|
|
|
|
wget -O- "${{ needs.check-upstream.outputs.tarball_url }}" | tar xz
|
|
|
|
mv tonarino-innernet-*/* .
|
|
|
|
rm -fr tonarino-innernet-*
|
|
|
|
|
2023-02-17 14:13:44 +00:00
|
|
|
- name: Install Rust
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2023-02-17 14:18:38 +00:00
|
|
|
toolchain: stable
|
2023-02-17 14:13:44 +00:00
|
|
|
profile: minimal
|
|
|
|
override: true
|
|
|
|
|
|
|
|
- name: Install cargo-deb
|
|
|
|
run: |
|
|
|
|
type -p cargo-deb || cargo install cargo-deb
|
|
|
|
|
2023-02-17 14:51:29 +00:00
|
|
|
- name: Set Up Rust Cache
|
2023-02-17 14:13:44 +00:00
|
|
|
uses: Swatinem/rust-cache@v1
|
2023-05-01 07:25:15 +00:00
|
|
|
with:
|
|
|
|
key: ${{ matrix.os }}
|
|
|
|
|
2023-02-17 14:13:44 +00:00
|
|
|
- name: Build Client DEB
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: deb
|
2023-05-12 14:25:01 +00:00
|
|
|
args: -p client --deb-version=${{ needs.check-upstream.outputs.innernet_version }}-0ubuntu0~${{ steps.translate-codename.outputs.codename }}
|
2023-05-01 07:25:15 +00:00
|
|
|
|
2023-02-17 14:13:44 +00:00
|
|
|
- name: Build Server DEB
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: deb
|
2023-05-12 14:25:01 +00:00
|
|
|
args: -p server --deb-version=${{ needs.check-upstream.outputs.innernet_version }}-0ubuntu0~${{ steps.translate-codename.outputs.codename }}
|
2021-09-11 09:37:29 +00:00
|
|
|
|
2023-02-17 14:13:44 +00:00
|
|
|
- name: Upload DEBs
|
2023-05-12 13:21:21 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-09-11 09:37:29 +00:00
|
|
|
with:
|
2023-05-12 14:25:01 +00:00
|
|
|
name: deb-${{ matrix.os }}
|
2023-02-17 14:51:29 +00:00
|
|
|
path: target/debian/*.deb
|
2023-05-01 07:25:15 +00:00
|
|
|
|
2023-05-12 14:25:01 +00:00
|
|
|
- name: Show Output
|
|
|
|
id: show-output
|
|
|
|
run: |
|
|
|
|
echo "## Job Outputs" >>"$GITHUB_STEP_SUMMARY"
|
|
|
|
echo "* \`codename=${{ steps.translate-codename.outputs.codename }}\`" >>"$GITHUB_STEP_SUMMARY"
|
|
|
|
|
2023-02-17 14:13:44 +00:00
|
|
|
release:
|
2023-03-20 16:33:34 +00:00
|
|
|
needs: [check-upstream, build-deb]
|
2023-05-01 07:25:15 +00:00
|
|
|
# Avoid push conflicts.
|
|
|
|
concurrency: update_repository
|
2023-05-15 15:19:44 +00:00
|
|
|
if: "matrix.os[0] != null"
|
2023-05-01 07:25:15 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-05-12 14:08:56 +00:00
|
|
|
os: ${{ fromJson(needs.check-upstream.outputs.new_release_exists) }}
|
2023-02-17 14:13:44 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Install Distro Dependencies
|
2023-02-17 14:51:29 +00:00
|
|
|
run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes git gpg reprepro
|
2021-09-11 09:37:29 +00:00
|
|
|
|
2023-02-17 14:51:29 +00:00
|
|
|
- name: Set Up GPG Keys
|
2021-09-11 10:32:50 +00:00
|
|
|
run: |
|
2021-09-11 11:16:10 +00:00
|
|
|
mkdir -p -m 0700 "$HOME/.gnupg"
|
2021-09-11 11:19:43 +00:00
|
|
|
echo 'pinentry-mode loopback' >>"$HOME/.gnupg/gpg.conf"
|
|
|
|
echo 'allow-loopback-pinentry' >>"$HOME/.gnupg/gpg-agent.conf"
|
|
|
|
echo 'allow-preset-passphrase' >>"$HOME/.gnupg/gpg-agent.conf"
|
2021-09-11 11:06:31 +00:00
|
|
|
gpgconf --reload gpg-agent
|
2021-09-11 10:32:50 +00:00
|
|
|
echo "${{ secrets.GPG_SIGNING_KEY }}" | gpg --quiet --batch --yes --import
|
2021-09-11 11:21:31 +00:00
|
|
|
echo '${{ secrets.GPG_SIGNING_PASSPHRASE }}' | /usr/lib/gnupg/gpg-preset-passphrase --preset 57F0E65446A301CC19914FD61167922350A2D8B2
|
2023-02-17 14:51:29 +00:00
|
|
|
|
2023-05-12 14:25:01 +00:00
|
|
|
- name: Translate Codename
|
|
|
|
id: translate-codename
|
|
|
|
run: |
|
|
|
|
case "${{ matrix.os }}" in
|
2023-05-12 14:28:29 +00:00
|
|
|
ubuntu-22.04) codename=jammy ;;
|
|
|
|
ubuntu-20.04) codename=focal ;;
|
2023-05-12 14:25:01 +00:00
|
|
|
*)
|
|
|
|
echo "Unknown OS: ${{ matrix.os }}" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "codename=$codename" >>"$GITHUB_OUTPUT"
|
|
|
|
|
2023-02-17 14:51:29 +00:00
|
|
|
- name: Checkout
|
2023-05-12 13:21:21 +00:00
|
|
|
uses: actions/checkout@v3
|
2023-02-17 14:51:29 +00:00
|
|
|
with:
|
|
|
|
# See https://github.com/marketplace/actions/github-push
|
|
|
|
persist-credentials: false
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-05-12 14:25:01 +00:00
|
|
|
- name: Download DEBs
|
2023-05-12 13:21:21 +00:00
|
|
|
uses: actions/download-artifact@v3
|
2023-02-17 14:13:44 +00:00
|
|
|
with:
|
2023-05-12 14:25:01 +00:00
|
|
|
name: deb-${{ matrix.os }}
|
2023-02-17 14:51:29 +00:00
|
|
|
path: ./artifacts
|
2023-05-01 07:25:15 +00:00
|
|
|
|
2023-05-12 14:25:01 +00:00
|
|
|
- name: Import DEBs
|
2023-02-17 14:51:29 +00:00
|
|
|
run: |
|
|
|
|
cd artifacts
|
|
|
|
for name in *.deb; do
|
2023-05-12 14:25:01 +00:00
|
|
|
reprepro --export=silent-never -b ../debian includedeb "${{ steps.translate-codename.outputs.codename }}" "$name"
|
2023-02-17 14:51:29 +00:00
|
|
|
done
|
2023-05-01 07:25:15 +00:00
|
|
|
|
2023-02-17 14:13:44 +00:00
|
|
|
- name: Update Repository
|
2023-02-17 14:51:29 +00:00
|
|
|
run: |
|
|
|
|
has_changes() {
|
|
|
|
git status --porcelain "$@" | grep -q .
|
|
|
|
}
|
|
|
|
|
|
|
|
if has_changes debian/pool; then
|
2023-05-12 14:25:01 +00:00
|
|
|
reprepro -b debian export "${{ steps.translate-codename.outputs.codename }}"
|
2023-02-17 14:51:29 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if has_changes debian/{db,dists,pool}; then
|
|
|
|
git add debian/{db,dists,pool}
|
|
|
|
git \
|
|
|
|
-c 'user.email=41898282+github-actions[bot]@users.noreply.github.com' \
|
|
|
|
-c 'user.name=github-actions[bot]' \
|
2023-05-12 14:25:01 +00:00
|
|
|
commit -m "Included release tonarino/innernet@${{ needs.check-upstream.outputs.innernet_release }} in ${{ steps.translate-codename.outputs.codename }}."
|
2023-02-17 14:51:29 +00:00
|
|
|
else
|
|
|
|
echo 'No updates to commit.'
|
|
|
|
fi
|
2021-09-11 09:37:29 +00:00
|
|
|
|
|
|
|
- name: Push changes
|
2023-05-12 13:11:21 +00:00
|
|
|
uses: ad-m/github-push-action@master
|
2023-05-01 07:25:15 +00:00
|
|
|
if: github.ref_name == 'main'
|
2021-09-11 09:37:29 +00:00
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
2021-09-11 09:51:17 +00:00
|
|
|
branch: ${{ github.ref }}
|
2023-05-12 13:11:21 +00:00
|
|
|
|
|
|
|
# GitHub shows an inconsistent delay with pulling right after pushing. Since we push
|
|
|
|
# for multiple distributions, we have to make sure the next checkout doesn't conflict
|
|
|
|
# with the current.
|
|
|
|
- name: Delay 30 seconds for pushed changes to be visible
|
|
|
|
run: sleep 30s
|
|
|
|
shell: bash
|