Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Distribution (APT and WASM) #80

Distribution (APT and WASM)

Distribution (APT and WASM) #80

Workflow file for this run

name: Distribution (APT and WASM)
on:
# Used when nigthly builds needs to be refreshed or
# a tag should be added to main components
workflow_dispatch:
inputs:
refresh-nightly:
description: "Trigger a rebuild of today's nightly builds"
required: false
type: boolean
default: false
tag:
description: "Tag to build and add to the main components"
required: false
type: string
reset:
description: "Reset all published artifacts and start fresh"
required: false
type: boolean
default: false
# Used when publishing the release as main components
release:
types: [published]
# Used to build nightly releases
schedule:
- cron: "0 0 * * *" # Every day at midnight
# Only one distribution workflow can run at a time
concurrency:
group: "distribution"
cancel-in-progress: false
env:
DEBIAN_FRONTEND: noninteractive
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
types: ${{ steps.set-types.outputs.types }}
main-tag: ${{ steps.decide-main-tag.outputs.tag }}
steps:
- name: Check workflow inputs
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
if [ "${{ github.event.inputs.reset }}" = "false" ] && [ -z "${{ github.event.inputs.tag }}" ] && [ "${{ github.event.inputs.refresh-nightly }}" = "false" ]; then
echo "Error: 'tag' input must be provided when 'reset' and 'refresh-nightly' are both false."
exit 1
fi
- name: Get cached commit
id: get-latest-commit
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/gpac-latest-commit.txt
key: gpac-latest-commit-${{ github.sha }}
restore-keys: |
gpac-latest-commit-
- name: Get latest gpac commit
id: git-status
run: |
LATEST_COMMIT=$(git ls-remote --refs https://github.com/gpac/gpac.git refs/heads/master | awk '{print $1}')
echo $LATEST_COMMIT > ${{ runner.temp }}/gpac-latest-commit.txt
echo "has_new_commits=$(if [ "${{ steps.get-latest-commit.outputs.cache-hit }}" = "false" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
- name: Set types
id: set-types
run: |
types=()
# Add "main" type if:
# - release event
# - manual tag input
# - manual reset
if {
[[ "${{ github.event_name }}" == "release" ]] ||
[[ -n "${{ github.event.inputs.tag }}" ]] ||
[[ "${{ github.event.inputs.reset }}" == "true" ]];
}; then
types+=("\"main\"")
fi
# Add "nightly" type if:
# - scheduled run and had new commits since last run
# - manual refresh-nightly and had new commits since last run
# - manual reset
has_new_commits="${{ steps.git-status.outputs.has_new_commits }}"
if {
[[ "${{ github.event_name }}" == "schedule" && "$has_new_commits" == "true" ]] ||
[[ "${{ github.event.inputs.refresh-nightly }}" == "true" && "$has_new_commits" == "true" ]] ||
[[ "${{ github.event.inputs.reset }}" == "true" ]];
}; then
types+=("\"nightly\"")
fi
echo "types=[$(IFS=,; echo "${types[*]}")]" >> $GITHUB_OUTPUT
- name: Decide main tag
id: decide-main-tag
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
elif [[ -n "${{ github.event.inputs.tag }}" ]]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
# Get the latest v* tag from gpac/gpac repo
LATEST_TAG=$(git ls-remote --tags https://github.com/gpac/gpac.git | awk -F/ '/refs\/tags\/v[0-9]/{print $3}' | sort -V | tail -n1)
if [ -z "$LATEST_TAG" ]; then
echo "Error: No v* tag found in gpac/gpac repository."
exit 1
else
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
fi
fi
- name: Workflow summary
run: |
echo "## Distribution Workflow Summary" >> $GITHUB_STEP_SUMMARY
echo "### Latest GPAC Commit" >> $GITHUB_STEP_SUMMARY
echo "$(cat ${{ runner.temp }}/gpac-latest-commit.txt)" >> $GITHUB_STEP_SUMMARY
echo "### New Commits Detected" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.git-status.outputs.has_new_commits }}" = "true" ]; then
echo "Yes" >> $GITHUB_STEP_SUMMARY
else
echo "No" >> $GITHUB_STEP_SUMMARY
fi
echo "### Inputs" >> $GITHUB_STEP_SUMMARY
echo "- Tag: ${{ github.event.inputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- Reset: ${{ github.event.inputs.reset }}" >> $GITHUB_STEP_SUMMARY
echo "- Refresh Nightly: ${{ github.event.inputs.refresh-nightly }}" >> $GITHUB_STEP_SUMMARY
echo "### Types to Build" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.set-types.outputs.types }}" = "[]" ]; then
echo "No types to build." >> $GITHUB_STEP_SUMMARY
else
echo '${{ steps.set-types.outputs.types }}' | jq -r '.[]' | while read -r type; do
echo "- $type" >> $GITHUB_STEP_SUMMARY
done
fi
echo "### Main Tag" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.decide-main-tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
build-linux:
strategy:
matrix:
type: ${{ fromJson(needs.prepare.outputs.types) }}
name: Build Linux (${{ matrix.type || 'unknown' }})
needs: prepare
if: ${{ needs.prepare.outputs.types != '[]' }}
uses: ./.github/workflows/dist-linux.yml
with:
tag: ${{ matrix.type == 'main' && needs.prepare.outputs.main-tag || 'nightly' }}
secrets: inherit
build-wasm:
strategy:
matrix:
type: ${{ fromJson(needs.prepare.outputs.types) }}
exclude:
- type: main # We'll build main on v2.5+
name: Build WASM (${{ matrix.type || 'unknown' }})
needs: prepare
if: ${{ needs.prepare.outputs.types != '[]' }}
uses: ./.github/workflows/dist-wasm.yml
with:
tag: ${{ matrix.type == 'main' && needs.prepare.outputs.main-tag || 'nightly' }}
secrets: inherit
publish:
name: Publish artifacts
needs: [prepare, build-linux, build-wasm]
runs-on: ubuntu-latest
if: ${{ needs.prepare.outputs.types != '[]' }}
services:
http:
image: nginx:alpine
ports:
- 8080:80
volumes:
- ${{ github.workspace }}/ftp:/usr/share/nginx/html
options: --name nginx
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: .github
- name: Add scripts to PATH
run: echo "${{ github.workspace }}/.github/scripts" >> $GITHUB_PATH
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y aptly lftp
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
trust_level: 5 # ultimate
- name: Mirror FTP server
if: ${{ github.event.inputs.reset != 'true' }}
run: |
lftp -e "
set ssl:verify-certificate no
set net:reconnect-interval-base 2
set mirror:parallel-transfer-count 8
open ${{ secrets.FTP_HOST }}
user ${{ secrets.FTP_USERNAME }} ${{ secrets.FTP_PASSWORD }}
mirror -v / ftp
bye
"
- name: Restart nginx -- feed the volume
uses: docker://docker
with:
args: docker restart nginx
- name: Create and Mirror repositories
env:
SKIP_MIRROR: ${{ github.event.inputs.reset || 'false' }}
run: publish.py mirror
- name: Publish artifacts
run: publish.py publish
- name: Export public key
run: gpg --armor --export "${{ steps.import-gpg.outputs.fingerprint }}" > "$HOME/.aptly/public/gpg.asc"
- name: Create public directory
run: |
mkdir -p public/linux
mkdir -p public/wasm
cp -r "$HOME/.aptly/public"/* public/linux/
cp -r /tmp/wasm-mirror/* public/wasm/
- name: Print the public directory
run: tree public
- name: Deploy via lftp
run: |
lftp -e "
set ssl:verify-certificate no
set net:reconnect-interval-base 2
set mirror:parallel-transfer-count 8
open ${{ secrets.FTP_HOST }}
user ${{ secrets.FTP_USERNAME }} ${{ secrets.FTP_PASSWORD }}
mirror -v -R public / --delete --exclude-glob .htaccess
bye
"