105 lines
3.3 KiB
YAML
105 lines
3.3 KiB
YAML
name: Publish
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
env:
|
|
CHECKOUT_ACTION: actions/checkout@v4
|
|
PKGBASE_PARSER: ${{ gitea.server_url }}/${{ gitea.repository_owner }}/pkgbase-yaml-parser@v0
|
|
|
|
jobs:
|
|
check-workflow:
|
|
runs-on: ubuntu-latest
|
|
name: Check workflow
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: ${{ env.CHECKOUT_ACTION }}
|
|
|
|
- name: Retrieve latest
|
|
env:
|
|
WORKFLOW_URL: ${{ gitea.server_url }}/${{ gitea.repository_owner }}/package_template/raw/branch/master/.gitea/workflows/publish.yml
|
|
run: |
|
|
echo "Retrieving latest workflow from $WORKFLOW_URL" && \
|
|
curl -f -o ".gitea/workflows/publish.yml" "$WORKFLOW_URL"
|
|
|
|
- name: check for diff
|
|
run: git update-index --refresh
|
|
|
|
build:
|
|
needs: check-workflow
|
|
runs-on: ubuntu-latest
|
|
name: Build and publish
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: ${{ env.CHECKOUT_ACTION }}
|
|
|
|
- name: Parse pkgbase
|
|
uses: ${{ env.PKGBASE_PARSER }}
|
|
id: parsed
|
|
with:
|
|
previous: ${{ gitea.server_url }}/${{ gitea.repository }}/raw/tag/latest/.artixlinux/pkgbase.yaml
|
|
current: .artixlinux/pkgbase.yaml
|
|
|
|
- name: Move package
|
|
uses: ${{ env.PKGBASE_PARSER }}
|
|
if: ${{ steps.parsed.outputs.move == 'true' }}
|
|
with:
|
|
mode: move
|
|
parsed-data: ${{ steps.parsed.outputs.parsed-data }}
|
|
username: "${{ secrets.USERNAME }}"
|
|
token: ${{ secrets.TOKEN }}
|
|
|
|
- name: Create publish script
|
|
shell: bash
|
|
if: ${{ steps.parsed.outputs.build == 'true' }}
|
|
run: |
|
|
echo "#!/bin/bash
|
|
echo '📤️ Uploading package to ${{ gitea.server_url }} ...'
|
|
for f in ./*.tar.zst; do
|
|
[ -f \"\$f\" ] || continue
|
|
curl -f --user \"\$username:\$token\" \
|
|
--upload-file \"\$f\" \
|
|
'${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/arch/${{ steps.parsed.outputs.destination }}'
|
|
done
|
|
" > "./post-entrypoint.sh"
|
|
chmod +x "./post-entrypoint.sh"
|
|
git config --global user.name 'Guy Incognito'
|
|
git config --global user.email 'user@local'
|
|
git add "./post-entrypoint.sh" && \
|
|
git commit -m "persist publish script" && \
|
|
cat "./post-entrypoint.sh"
|
|
|
|
- name: Build package
|
|
uses: ${{ gitea.server_url }}/${{ gitea.repository_owner }}/build-publish/@build
|
|
if: ${{ steps.parsed.outputs.build == 'true' }}
|
|
with:
|
|
username: "${{ secrets.USERNAME }}"
|
|
token: ${{ secrets.TOKEN }}
|
|
|
|
- name: Revert publish script
|
|
shell: bash
|
|
if: ${{ steps.parsed.outputs.build == 'true' }}
|
|
run: git reset --hard HEAD~1
|
|
|
|
- name: Delete package
|
|
uses: ${{ env.PKGBASE_PARSER }}
|
|
if: ${{ steps.parsed.outputs.delete == 'true' }}
|
|
with:
|
|
mode: delete
|
|
parsed-data: ${{ steps.parsed.outputs.parsed-data }}
|
|
username: "${{ secrets.USERNAME }}"
|
|
token: ${{ secrets.TOKEN }}
|
|
|
|
- name: Update latest tag
|
|
shell: bash
|
|
run: |
|
|
git config user.name "Gitea CI"
|
|
git config user.email "ci@gitea.local"
|
|
git tag -f latest
|
|
git push origin -f latest
|