Skip to content

Commit

Permalink
Update package-build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mirostauder authored Mar 8, 2023
1 parent 64f43e5 commit e4d0c62
Showing 1 changed file with 80 additions and 24 deletions.
104 changes: 80 additions & 24 deletions .github/workflows/package-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,28 @@ concurrency:
# cancel-in-progress: true

jobs:
clean:
runs-on: ubuntu-22.04
steps:
- name: Clean packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# gh release delete-asset v2.x-head
gh release delete v2.x-head --repo ${{ github.repository }} --cleanup-tag || true
gh release create v2.x-head --repo ${{ github.repository }} --title v2.x-head --draft --prerelease --notes-file - << EOF
## Development Snapshot
GH-Action Package-Build on PR merge into v2.x
Started : **$(date '+%Y-%m-%d %H:%M:%S %Z')**
Status : **Build in progress**
EOF
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: [ clean ]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -51,7 +71,7 @@ jobs:
type: '-clang'
- dist: 'ubuntu18'
type: '-clang'

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -64,33 +84,49 @@ jobs:
run: |
git fetch --tags --force
echo "GIT_VERSION=$(git describe --long --abbrev=7)" >> $GITHUB_ENV
- name: Update release
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${{ matrix.dist }}" = "centos7" ]] && [[ "${{ matrix.type }}" = "" ]]; then
gh release edit v2.x-head --draft --prerelease --repo ${{ github.repository }} --tag v2.x-head --title "v2.x-head - ${GIT_VERSION}" --notes-file - << EOF
## Development Snapshot
GH-Action Package-Build on PR merge into v2.x
Updated : **$(date '+%Y-%m-%d %H:%M:%S %Z')**
Status : **Build in progress**
EOF
fi
- name: Build package
run: |
make ${{ matrix.dist }}${{ matrix.type }}
# - name: Deploy to Repo
# uses: easingthemes/ssh-deploy@main
# env:
# SSH_PRIVATE_KEY: ${{ secrets.REPO_PRIVATE_KEY }}
# ARGS: "-ai"
# SOURCE: "binaries/"
# REMOTE_HOST: ${{ secrets.REPO_HOST }}
# REMOTE_USER: ${{ secrets.REPO_USER }}
# TARGET: ${{ secrets.REPO_TARGET }}/binaries-${{ env.GIT_VERSION }}
# EXCLUDE: "binaries/.gitignore"
# SCRIPT_BEFORE: |
# ls -ld ${{ secrets.REPO_TARGET }}/*
# (ls -1d ${{ secrets.REPO_TARGET }}/binaries-* || true) | sort -r | tail -n +10 | xargs -n1 rm -rf
# rm -rf ${{ secrets.REPO_TARGET }}/binaries-${{ env.GIT_VERSION }}

- name: Publish release
echo "BIN_PKG=$(ls -1 binaries/*[mb])" >> $GITHUB_ENV
echo "BIN_HASH=$(ls -1 binaries/*.id-hash)" >> $GITHUB_ENV
- name: Deploy to Repo
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.REPO_PRIVATE_KEY }}
ARGS: "-aic"
SOURCE: ${{ env.BIN_PKG }}
REMOTE_HOST: ${{ secrets.REPO_HOST }}
REMOTE_USER: ${{ secrets.REPO_USER }}
TARGET: ${{ secrets.REPO_TARGET }}/binaries-${{ env.GIT_VERSION }}/
EXCLUDE: binaries/.gitignore

- name: Push packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo -e "### Development Snapshot\n\nGH-Action Package-Build on PR merge into v2.x\n\ngit describe : **${GIT_VERSION}**" | gh release edit v2.x-head --draft --prerelease --repo sysown/proxysql --notes-file -
gh release upload v2.x-head --repo sysown/proxysql --clobber binaries/proxysql*${{ matrix.dist }}*[mb]
# git tag --force -a v2.x-head -m 'GH-Actions - Development Snapshot Build'
# git push origin --tags
# gh release upload v2.x-head --repo ${{ github.repository }} --clobber binaries/proxysql*${{ matrix.dist }}*[mb]
gh release upload v2.x-head --repo ${{ github.repository }} --clobber ${{ env.BIN_PKG }}
- name: Archive artifacts
if: always()
uses: actions/upload-artifact@v3
Expand All @@ -99,5 +135,25 @@ jobs:
path: |
./binaries/
!./**/.gitignore

finalize:
runs-on: ubuntu-22.04
needs: [ build ]
steps:
- name: Update release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release edit v2.x-head --draft --prerelease --repo ${{ github.repository }} --tag v2.x-head --notes-file - << EOF
## Development Snapshot
GH-Action Package-Build on PR merge into v2.x
Finished : **$(date '+%Y-%m-%d %H:%M:%S %Z')**
Status : **Build in finished**
[![Package-Build](https://github.com/${{ github.repository }}/actions/workflows/package-build.yml/badge.svg)](https://github.com/${{ github.repository }}/actions/workflows/package-build.yml)

0 comments on commit e4d0c62

Please sign in to comment.