Update workflow #13
This file contains hidden or 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: "virtualmin+cloudmin.dev: virtualmin/slib" | |
| on: | |
| push: | |
| branches: | |
| - master | |
| release: | |
| types: | |
| - prereleased | |
| - released | |
| env: | |
| GH_REPO: ${{ github.repository }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| IS_RELEASE: ${{ github.event_name == 'release' }} | |
| IS_PRERELEASE: ${{ github.event.release.prerelease || false }} | |
| BUILD_DEPS: "curl" | |
| BUILD_BOOTSTRAP: "https://raw.githubusercontent.com/webmin/webmin-ci-cd/main/build/bootstrap.bash" | |
| jobs: | |
| build-amd64: | |
| runs-on: ubuntu-latest | |
| if: ${{ !contains(github.event.head_commit.message, '[no-build]') }} | |
| env: | |
| TZ: Europe/Nicosia | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: ${{ env.BUILD_DEPS }} | |
| version: 1.0 | |
| - name: Fetch dependencies | |
| run: curl -O ${{ env.BUILD_BOOTSTRAP }} | |
| - name: Set timezone | |
| run: sudo timedatectl set-timezone ${{ env.TZ }} | |
| - name: Upload file | |
| env: | |
| CLOUD__IP_ADDR: ${{ secrets.DEV_IP_ADDR }} | |
| CLOUD__IP_KNOWN_HOSTS: ${{ secrets.DEV_IP_KNOWN_HOSTS }} | |
| CLOUD__UPLOAD_SSH_USER: ${{ secrets.DEV_UPLOAD_SSH_USER }} | |
| CLOUD__UPLOAD_SSH_DIR_VM: ${{ env.IS_RELEASE == 'true' && secrets.PRERELEASE_UPLOAD_SSH_DIR_VM || secrets.DEV_UPLOAD_SSH_DIR_VM }} | |
| CLOUD__UPLOAD_SSH_DIR_CM: ${{ env.IS_RELEASE == 'true' && secrets.PRERELEASE_UPLOAD_SSH_DIR_CM || secrets.DEV_UPLOAD_SSH_DIR_CM }} | |
| CLOUD__SSH_PRV_KEY: ${{ secrets.DEV_SSH_PRV_KEY }} | |
| CLOUD__SIGN_BUILD_REPOS_CMD: ${{ secrets.DEV_SIGN_BUILD_REPOS_CMD }} | |
| run: |- | |
| # Fail on error | |
| set -euo pipefail | |
| # Bootstrap build | |
| source bootstrap.bash $([[ "$IS_RELEASE" == "true" ]] || echo "--testing") $([[ "$IS_PRERELEASE" == "true" ]] && echo "--prerelease") | |
| source bootstrap.bash \ | |
| $([[ "$IS_RELEASE" != "true" ]] && echo "--testing") \ | |
| $([[ "$IS_PRERELEASE" == "true" ]] && echo "--prerelease") | |
| # Get package version | |
| pkg_version=$(get_remote_git_tag_version "$GH_REPO" "$GH_TOKEN" "$IS_RELEASE") | |
| # Prepare build | |
| slib_versioned="slib-$pkg_version.sh" | |
| cp -p slib.sh "$slib_versioned" | |
| # Delete previous versions and upload new files (Virtualmin) | |
| export CLOUD_UPLOAD_SSH_DIR=$CLOUD__UPLOAD_SSH_DIR_VM | |
| upload_list=("slib.sh" "$slib_versioned") | |
| delete_list=("$CLOUD_UPLOAD_SSH_DIR slib * *sh") | |
| cloud_upload upload_list delete_list | |
| # Delete previous versions and upload new files (Cloudmin) | |
| export CLOUD_UPLOAD_SSH_DIR=$CLOUD__UPLOAD_SSH_DIR_CM | |
| upload_list=("slib.sh" "$slib_versioned") | |
| delete_list=("$CLOUD_UPLOAD_SSH_DIR slib * *sh") | |
| cloud_upload upload_list delete_list |