Files
package_template/.gitea/workflows/publish.yml
2025-11-12 15:02:43 -05:00

109 lines
3.4 KiB
YAML

name: Publish
on:
push:
branches:
- master
paths:
- ".artixlinux/pkgbase.yaml"
env:
CHECKOUT_ACTION: actions/checkout@v4
PKGBASE_PARSER: https://git.sanin.dev/packages_infra/pkgbase-yaml-parser@v1
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: https://git.sanin.dev/packages_infra/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: https://git.sanin.dev/packages_infra/makepkg-build-action@v1-artix
if: ${{ steps.parsed.outputs.build == 'true' }}
with:
username: "${{ secrets.USERNAME }}"
token: ${{ secrets.TOKEN }}
deps: ${{ steps.parsed.outputs.deps }}
tier: ${{ steps.parsed.outputs.tier }}
- 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