Build and release #849
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and release | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
- cron: "0 */12 * * *" | |
env: | |
RELEASE_TAG: packages | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
env: | |
KEYFILE: keyfile.toml | |
permissions: write-all | |
outputs: | |
matrix: ${{ steps.checker.outputs.matrix }} | |
build_status: ${{ steps.checker.outputs.build_status }} | |
remove_status: ${{ steps.checker.outputs.remove_status }} | |
remove_pkgs: ${{ steps.checker.outputs.remove_pkgs }} | |
steps: | |
- name: Checkout to repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: changed-files | |
run: | | |
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT | |
- name: Set keyfile.toml | |
run: | | |
if [ ! -f ${{ env.KEYFILE }} ]; then | |
echo "${{ env.KEYFILE }} not found" | |
exit 1 | |
fi | |
sed -i -e "s/__GITHUB_ACCESS_TOKEN__/${{ github.token }}/g" ${{ env.KEYFILE }} | |
- name: nvchecker and update | |
id: checker | |
uses: ./nvcheck-and-update | |
with: | |
changed_files: ${{ steps.changed-files.outputs.changed_files }} | |
keyfile: ${{ env.KEYFILE }} | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
if: steps.checker.outputs.build_status == 'true' || steps.checker.outputs.remove_status == 'true' | |
with: | |
file_pattern: ${{ steps.checker.outputs.oldver_file }} | |
commit_message: ⏰ auto updated oldver file | |
Repo_Remove: | |
if: needs.check.outputs.remove_status == 'true' | |
runs-on: ubuntu-latest | |
permissions: write-all | |
needs: check | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Remove old packages | |
uses: ./repo-action | |
env: | |
GH_TOKEN: ${{ github.token }} | |
with: | |
request: "remove" | |
remove_pkgs: ${{ needs.check.outputs.remove_pkgs }} | |
- name: Update repo db | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
files: | | |
${{ github.workspace }}/*.files | |
${{ github.workspace }}/*.files.tar.gz | |
${{ github.workspace }}/*.db | |
${{ github.workspace }}/*.db.tar.gz | |
generate_release_notes: true | |
Build: | |
if: needs.check.outputs.build_status == 'true' | |
permissions: write-all | |
needs: check | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.check.outputs.matrix) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: ./arch-build | |
id: build | |
with: | |
pkg: ${{ matrix.pkg }} | |
version: ${{ matrix.version }} | |
- name: Pull Remote Changes | |
run: git pull --rebase --autostash | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
file_pattern: "${{ matrix.pkg }}/PKGBUILD" | |
commit_message: ⏰ ${{ matrix.pkg }}:auto updated to ${{ matrix.version }} | |
- name: Upload Packages Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build.outputs.asset }} | |
path: ${{ matrix.pkg }}/${{ steps.build.outputs.asset }} | |
if-no-files-found: error | |
- name: Delete old asset | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
assets=$(gh release view --json assets | jq -r '.assets[].name') | |
if [[ "$assets" =~ ${{ matrix.pkg }}-${{ matrix.old_pkgver }}.*pkg.tar.zst ]]; then | |
pkg_assets=$(echo "$assets" | grep -E "^${{ matrix.pkg }}-${{ matrix.old_pkgver }}.*pkg.tar.zst") | |
for asset in $pkg_assets; do | |
echo "Deleting asset: $asset" | |
gh release delete-asset packages "$asset" -y | |
done | |
else | |
echo "No matching assets found. Exiting with code 0." | |
exit 0 | |
fi | |
Release: | |
needs: [Build, Repo_Remove] | |
if: ${{ !cancelled() && (needs.Build.result == 'success' || needs.Repo_Remove.result == 'success') }} | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Pull Remote Changes | |
run: git pull --rebase --autostash | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- uses: ./repo-action | |
env: | |
GH_TOKEN: ${{ github.token }} | |
with: | |
request: "add" | |
- name: Upload Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
files: | | |
${{ github.workspace }}/*.pkg.tar.zst | |
${{ github.workspace }}/*.files | |
${{ github.workspace }}/*.db | |
${{ github.workspace }}/*.db.tar.gz | |
generate_release_notes: true | |
- name: Send notify to telegram | |
uses: appleboy/telegram-action@master | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
format: markdown | |
message: "From ${{ github.repository }} - ${{ github.workflow }}: \n Packages build success!\n[View it On Github](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\n" |