Skip to content

TEST: Test the workflow changes #327

TEST: Test the workflow changes

TEST: Test the workflow changes #327

Workflow file for this run

name: Native CI/CD
on:
push:
paths:
- .github/workflows/native.yaml
- native/**
tags:
- v*
branches-ignore:
- crowdin-*
pull_request:
paths:
- .github/workflows/native.yaml
- native/**
defaults:
run:
shell: bash
jobs:
release-gentoo:
name: Release on Gentoo GURU
runs-on: ubuntu-latest
container: ghcr.io/filips123/gentoo-pycargoebuild
permissions:
contents: read
steps:
- name: Checkout project repository
uses: actions/checkout@v4
- name: Checkout GURU repository
uses: actions/checkout@v4
with:
repository: gentoo/guru
path: tmp/guru
fetch-depth: 0
- name: Configure cache
run: echo "CACHE_ID=$(date --utc '+%Y-%V')" >> $GITHUB_ENV
- name: Configure cache
uses: actions/cache@v3
with:
path: /var/cache/distfiles
key: gentoo-distfiles-${{ env.CACHE_ID }}
restore-keys: gentoo-distfiles-
- name: Import GPG key
run: echo "${{ secrets.GENTOO_KEY_PRIVATE }}" | gpg --import --batch
- name: Prepare Git user
working-directory: tmp/guru
run: |
git config --local user.name "${{ vars.GENTOO_USERNAME }}"
git config --local user.email "${{ vars.GENTOO_EMAIL }}"
git config --local user.signingkey "${{ secrets.GENTOO_KEY_ID }}"
- name: Prepare Git settings
working-directory: tmp/guru
run: |
git config --local pull.ff only
git config --local pull.rebase merges
git config --local commit.gpgsign 1
- name: Set the version
run: |
VERSION=2.14.0
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Generate updated package
working-directory: tmp/guru/www-plugins/firefoxpwa
run: |
echo "::group::Updating the package ebuild"
cp "$GITHUB_WORKSPACE/native/packages/gentoo/firefoxpwa.ebuild" "firefoxpwa-$VERSION.ebuild"
pycargoebuild -i "firefoxpwa-$VERSION.ebuild" "$GITHUB_WORKSPACE/native"
echo "::endgroup::"
echo "::group::Updating the package manifest"
ebuild "firefoxpwa-$VERSION.ebuild" manifest
echo "::endgroup::"
- name: Commit updated package
working-directory: tmp/guru/www-plugins/firefoxpwa
run: |
git add -A
pkgdev commit --signoff
- name: Scan updated package
working-directory: tmp/guru/www-plugins/firefoxpwa
run: |
git remote set-head origin master
pkgcheck scan --net --commits
- name: Remove old packages
working-directory: tmp/guru/www-plugins/firefoxpwa
run: |
# Set the number of ebuilds to keep
PRESERVE=3
# Collect all ebuild files
files=(firefoxpwa-*.ebuild)
# Skip if there are not enough ebuilds
if [ "${#files[@]}" -le "$PRESERVE" ]
then
echo "No old ebuilds to remove"
exit 0
fi
# Get the time the ebuilds were created
timestamped=""
for file in "${files[@]}"
do
timestamp=$(git log --diff-filter=A --format=%at -1 -- "$file" 2> /dev/null || echo 0)
timestamped+="$timestamp $file"$'\n'
done
timestamped=$(echo "$timestamped" | sed '/^$/d')
# Sort the ebuilds by time
mapfile -t sorted < <(echo "$timestamped" | sort -n | awk '{print $2}')
# Remove all but the last few ebuilds
echo "::group::Removing old ebuilds"
dropped=$((${#sorted[@]} - PRESERVE))
for file in "${sorted[@]:0:$dropped}"
do
echo "Removing $file"
rm "$file"
done
echo "::endgroup::"
# Regenerate the manifest
echo "::group::Regenerating the manifest"
pkgdev manifest
echo "::endgroup::"
# Commit the changes
echo "::group::Committing the changes"
git add -A
pkgdev commit --signoff
echo "::endgroup::"