Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Deploying system package #130

Deploying system package

Deploying system package #130

Workflow file for this run

name: Deploying system package
on:
schedule:
- cron: "10 0 * * *" # run at the start of every day
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
public_key: ${{ secrets.PUBLIC }}
private_key: ${{ secrets.PRIVATE }}
jobs:
check-sha:
runs-on: ubuntu-latest
outputs:
match_results: ${{ steps.check-shas.outputs.match_results }}
remote_sha: ${{ steps.check-shas.outputs.remote_sha }}
steps:
- name: Checking out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Download remote commit shas
id: check-shas
run: |
# Download remote sha
latest_sha=$(curl -s https://api.github.com/repos/eupnea-project/system-update/commits/main | jq -r '.sha')
# fail if curl result is empty
if [[ "$latest_sha" = "null" ]]; then
echo "latest_tag is empty"
exit 1
fi
# Check remote sha against cached one
match_results=$([[ "$(cat cache/system_sha-cache.txt)" == "$latest_sha" ]] && echo "true" || echo "false")
echo "match_results=$match_results" >> $GITHUB_OUTPUT
# Add sha to output
echo "remote_sha=$latest_sha" >> $GITHUB_OUTPUT
deploy-system-package:
runs-on: ubuntu-latest
needs: check-sha # needs for the vars from the previous job
# Only run script when remote sha has changed, aka the results DON'T match
if: needs.check-sha.outputs.match_results == 'false'
steps:
- name: Checking out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Update local commits sha file
run: |
echo "${{ needs.check-sha.outputs.remote_sha }}" > cache/system_sha-cache.txt
- name: Install pacman
run: |
# Add ubuntu 22.10 repo to sources
echo "deb http://archive.ubuntu.com/ubuntu mantic main universe" | sudo tee -a /etc/apt/sources.list
# Update apt sources
sudo apt-get update
# Install pacman-package-manager from ubuntu 22.10 repo
sudo apt-get -y install pacman-package-manager libarchive-tools
# Set author in makepkg.conf
echo 'PACKAGER="The Eupnea Project <https://github.com/eupnea-project>"' | sudo tee -a /etc/makepkg.conf
- name: Bump version in pkgbuild file
run: |
CURRENT_VERSION=$(sed -n '3p' pkgbuild-files/system.pkgbuild | sed 's/.*://' | xargs) # get current version from control file
NEXTVERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}') # bump version
sed -i "3s/.*/${NEXTVERSION}/" pkgbuild-files/system.pkgbuild # update version in control file
- name: Packing eupnea-system package
run: |
cp pkgbuild-files/system.pkgbuild . # makepkg needs the pkgbuild file in the current directory
makepkg --nodeps -p system.pkgbuild
- name: Downloading old repo
run: |
# Download old repo.
# Exit in case the branch doesn't exist yet
git clone --branch=gh-pages https://github.com/eupnea-project/arch-repo /tmp/arch-repo || exit 0
# Copy old repo to current directory
cp -r /tmp/arch-repo/repodata .
# Delete old system packages
rm -rf repodata/x86_64/eupnea-system*.pkg.tar.gz
# Delete all signatures
rm -rf repodata/x86_64/*.sig
- name: Setting up arch repo
run: bash create-repo.sh
- name: Updating files in main branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
# Disable setting repo owner as commit author
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Update files in main branch
file_pattern: 'pkgbuild-files/system.pkgbuild cache/system_sha-cache.txt'
- name: Deploying system packages
uses: stefanzweifel/git-auto-commit-action@v4
with:
# Disable setting repo owner as commit author
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Deploy system packages
branch: gh-pages
create_branch: true
# Only include needed files
file_pattern: 'repodata/* public_key.gpg'
push_options: '--force'