components-template/.github/workflows/build_artifacts.yml

121 lines
4.3 KiB
YAML
Raw Normal View History

# Variables:
# - RUNNER_TAG: optional, defines on which runner the workflow will use, default ubuntu-latest
# - DYNAMIC_MANIFEST: optional, if set it will build the manifest from header.yml and module.yml files (json not yet supported)
# - MANIFEST_FILENAME: needed, the manifest name such as net.retrodeck.retrodeck.yaml
name: "Build Artifacts for RetroDECK main manifest"
on:
workflow_dispatch:
workflow_call:
2024-11-05 03:31:03 +00:00
inputs:
MANIFEST_FILENAME:
required: true
type: string
2024-11-05 06:11:28 +00:00
DYNAMIC_MANIFEST:
required: false
type: string
default: "false"
2024-11-05 02:07:08 +00:00
env:
DATE: ${{ github.run_id }}
jobs:
# Generate Rekku Token Job
Generate-Rekku-Token:
uses: RetroDECK/components-template/.github/workflows/generate_rekku_token.yml@main
secrets:
REKKU_PRIVATE_KEY: ${{ secrets.REKKU_PRIVATE_KEY }}
2024-11-05 02:07:08 +00:00
Building-project:
2024-11-05 03:02:38 +00:00
runs-on: ubuntu-latest
env:
REKKU_TOKEN: ${{ needs.Generate-Rekku-Token.outputs.rekku_token }}
2024-11-05 02:07:08 +00:00
steps:
2024-11-05 04:35:31 +00:00
2024-11-05 12:30:39 +00:00
- name: Prepearing environment
run: curl -s "https://raw.githubusercontent.com/RetroDECK/components-template/refs/heads/main/automation_tools/install_dependencies.sh" | /bin/bash
- name: Clone repo
2024-11-05 14:06:20 +00:00
uses: actions/checkout@v4
with:
submodules: 'true'
2024-11-05 13:24:46 +00:00
- name: Configuring Git
run: |
git config --global protocol.file.allow always
git config --global user.name "Rekku"
git config --global user.email "rekku@retrodeck.net"
2024-11-05 02:07:08 +00:00
- name: "Assembling manifest"
2024-11-05 06:11:28 +00:00
if: ${{ inputs.DYNAMIC_MANIFEST == 'true' }}
2024-11-05 02:07:08 +00:00
run: |
if [ -f "${GITHUB_WORKSPACE}/automation_tools/assemble_manifest.sh" ]; then
/bin/bash "${GITHUB_WORKSPACE}/automation_tools/assemble_manifest.sh"
else
echo "Manifest assembly script not found."
exit 1
fi
- name: "[DEBUG] Outputting manifest"
2024-11-05 06:11:28 +00:00
if: ${{ inputs.DYNAMIC_MANIFEST == 'true' }}
2024-11-05 02:07:08 +00:00
run: |
2024-11-05 06:11:28 +00:00
if [ -f "${{ inputs.MANIFEST_FILENAME }}" ]; then
cat "${{ inputs.MANIFEST_FILENAME }}"
2024-11-05 02:07:08 +00:00
else
2024-11-05 06:11:28 +00:00
echo "ERROR: manifest file not found: ${{ inputs.MANIFEST_FILENAME }}"
2024-11-05 02:07:08 +00:00
exit 1
fi
- name: "Build flatpak"
run: |
2024-11-05 12:30:39 +00:00
flatpak-builder --user --force-clean \
--install-deps-from=flathub \
--install-deps-from=flathub-beta \
--repo=${GITHUB_WORKSPACE}/artifacts-repo \
"${GITHUB_WORKSPACE}/artifacts-build-dir" \
"${{ inputs.MANIFEST_FILENAME }}"
2024-11-05 05:52:51 +00:00
- name: "Exporting dir tree"
id: tree
2024-11-05 02:07:08 +00:00
run: |
tree .
2024-11-05 02:07:08 +00:00
tree -H ./ > ${GITHUB_WORKSPACE}/tree.html
echo "Directory tree exported to tree.html"
2024-11-05 02:07:08 +00:00
- name: "Create Artifact for RetroDECK"
run: |
tar -czf ${GITHUB_WORKSPACE}/RetroDECK-Artifact.tar.gz -C ${GITHUB_WORKSPACE}/artifacts-build-dir .
hash=($(sha256sum ${GITHUB_WORKSPACE}/RetroDECK-Artifact.tar.gz))
echo $hash > ${GITHUB_WORKSPACE}/RetroDECK-Artifact.sha
2024-11-05 02:07:08 +00:00
- name: Upload Artifacts
2024-11-05 14:06:20 +00:00
uses: actions/upload-artifact@v4
2024-11-05 02:07:08 +00:00
with:
name: RetroDECK-Artifacts
path: |
${GITHUB_WORKSPACE}/RetroDECK-Artifact.tar.gz
${GITHUB_WORKSPACE}/tree.html
- name: Set environment variable with current branch name
run: echo "GITHUB_REF_SLUG=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
- name: Get branch name
id: branch_name
run: echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's|refs/heads/||')" >> $GITHUB_ENV
- name: Publish the artifacts in a new release
uses: ncipollo/release-action@v1
with:
2024-11-05 02:07:08 +00:00
tag: "${{ github.ref_name }}-${{ github.run_id }}"
body: |
# Release Notes
2024-11-05 02:07:08 +00:00
These are the artifacts for RetroDECK from ${{ github.repository }}, built from commit: ${{ github.repository }}@${{ github.sha }}.
On branch [${{ github.ref_name }}](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}).
artifacts: "RetroDECK-Artifact.tar.gz, tree.html, RetroDECK-Artifact.sha"
allowUpdates: true
makeLatest: true
2024-11-05 04:32:09 +00:00
token: ${{ steps.generate-rekku-token.outputs.token || secrets.TRIGGER_BUILD_TOKEN || secrets.GITHUB_TOKEN }}