From 7f3ee96fcef86e618e86b60ad9a0284246f50ca1 Mon Sep 17 00:00:00 2001 From: jsz Date: Fri, 11 Oct 2024 23:10:59 -0400 Subject: [PATCH] Switch to reusable workflows --- .../build-and-archive-debian-package.yml | 60 +++----------- .github/workflows/deploy-to-packagecloud.yml | 79 +++---------------- .github/workflows/python-style-police.yml | 2 +- .github/workflows/test-python-package.yml | 2 +- 4 files changed, 23 insertions(+), 120 deletions(-) diff --git a/.github/workflows/build-and-archive-debian-package.yml b/.github/workflows/build-and-archive-debian-package.yml index faf779b..651505a 100644 --- a/.github/workflows/build-and-archive-debian-package.yml +++ b/.github/workflows/build-and-archive-debian-package.yml @@ -5,62 +5,20 @@ on: pull_request: paths: - 'debian/changelog' -env: - debpackagename: wlanpi-core jobs: format: name: Get formatted version for filename uses: WLAN-Pi/gh-workflows/.github/workflows/get-formatted-version-string.yml@main sbuild: - name: sbuild ${{ matrix.distro }}+${{ matrix.arch }} pkg - runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}" - needs: format - strategy: - fail-fast: false - matrix: - distro: [bullseye,bookworm] - arch: [arm64] - steps: - # - name: Enable debug logging - # run: echo "Debug logging enabled" - # env: - # ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }} - - name: Validate formatted version output - run: | - if [ -z "${{ needs.format.outputs.version }}" ]; then - echo "Error: formatted version output is empty." - exit 1 - else - echo "Formatted version output: ${{ needs.format.outputs.version }}" - fi - - name: Get current date - id: date - run: echo "date=$(date -u +'%Y%m%d')" >> $GITHUB_ENV - - name: Get package filename - run: | - echo "filename=${{ env.debpackagename }}_${{ needs.format.outputs.version }}~gha${{ env.date }}+${{ matrix.arch }}_${{ matrix.distro }}" >> $GITHUB_ENV - - name: Checkout - uses: actions/checkout@v4 - - name: Validate Environment Variables - run: | - if [ -z "${{ env.debpackagename }}" ]; then - echo "Error: debpackagename cannot be empty" - exit 1 - fi - shell: bash - - name: sbuild deb pkg for ${{ matrix.distro }}+${{ matrix.arch }} - uses: wlan-pi/sbuild-debian-package@main - id: build-debian-package - with: - distro: ${{ matrix.distro }} - arch: ${{ matrix.arch }} - - name: Archive artifacts and upload to GitHub - uses: actions/upload-artifact@v4 - with: - name: ${{ env.filename }} - path: ${{ steps.build-debian-package.outputs.deb-package }} + name: sbuild pkg + needs: + - format + uses: WLAN-Pi/gh-workflows/.github/workflows/sbuild-pkg.yml@main + with: + pkg: wlanpi-core + version: ${{ needs.format.outputs.version }} slack-workflow-status: - if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }} + if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }} name: Post Workflow Status to Slack needs: - sbuild @@ -70,4 +28,4 @@ jobs: uses: Gamesight/slack-workflow-status@master with: repo_token: ${{ secrets.GITHUB_TOKEN }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file diff --git a/.github/workflows/deploy-to-packagecloud.yml b/.github/workflows/deploy-to-packagecloud.yml index 1f6755d..d6d48a0 100644 --- a/.github/workflows/deploy-to-packagecloud.yml +++ b/.github/workflows/deploy-to-packagecloud.yml @@ -7,8 +7,6 @@ on: - main paths: - 'debian/changelog' -env: - debpackagename: wlanpi-core jobs: check_version: name: Check py & deb pkg versions match @@ -18,74 +16,21 @@ jobs: format: name: Get formatted version for filename uses: WLAN-Pi/gh-workflows/.github/workflows/get-formatted-version-string.yml@main - sbuild: - name: sbuild ${{ matrix.distro }}+${{ matrix.arch }} pkg - runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}" - needs: [format, check_version] - strategy: - fail-fast: false - matrix: - distro: [bullseye,bookworm] - arch: [arm64] - environment: PACKAGECLOUD - steps: - - name: Validate formatted version output - run: | - if [ -z "${{ needs.format.outputs.version }}" ]; then - echo "Error: formatted version output is empty." - exit 1 - else - echo "Formatted version output: ${{ needs.format.outputs.version }}" - fi - - name: Get current date - id: date - run: echo "date=$(date -u +'%Y%m%d')" >> $GITHUB_ENV - - name: Gset package filename - run: | - echo "filename=${{ env.debpackagename }}_${{ needs.format.outputs.version }}~gha${{ env.date }}+${{ matrix.arch }}_${{ matrix.distro }}" >> $GITHUB_ENV - - name: Checkout - uses: actions/checkout@v4 - - name: Validate Environment Variables - run: | - if [ -z "${{ env.debpackagename }}" ]; then - echo "Error: debpackagename cannot be empty" - exit 1 - fi - shell: bash - - name: sbuild deb pkg for ${{ matrix.distro }}+${{ matrix.arch }} - uses: wlan-pi/sbuild-debian-package@main - id: build-debian-package - with: - distro: ${{ matrix.distro }} - arch: ${{ matrix.arch }} - - name: Archive artifacts and upload to GitHub - uses: actions/upload-artifact@v4 - with: - name: ${{ env.filename }} - path: ${{ steps.build-debian-package.outputs.deb-package }} - - name: Upload armhf pkg to raspbian/${{ matrix.distro }} - if: ${{ matrix.arch == 'armhf' && (github.repository_owner == 'WLAN-Pi') }} - uses: danielmundi/upload-packagecloud@main - with: - package-name: ${{ steps.build-debian-package.outputs.deb-package }} - packagecloud-username: wlanpi - packagecloud-repo: dev - packagecloud-distrib: raspbian/${{ matrix.distro }} - packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }} - - name: Upload arm64 pkg to debian/${{ matrix.distro }} - if: ${{ matrix.arch == 'arm64' && (github.repository_owner == 'WLAN-Pi') }} - uses: danielmundi/upload-packagecloud@main - with: - package-name: ${{ steps.build-debian-package.outputs.deb-package }} - packagecloud-username: wlanpi - packagecloud-repo: dev - packagecloud-distrib: debian/${{ matrix.distro }} - packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }} + sbuild_deploy: + name: sbuild deploy pkg + needs: + - format + - check_version + uses: WLAN-Pi/gh-workflows/.github/workflows/sbuild-deploy-pkg.yml@main + with: + pkg: wlanpi-core + version: ${{ needs.format.outputs.version }} + secrets: inherit slack-workflow-status: - if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }} + if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }} name: Post workflow status to Slack needs: - - sbuild + - sbuild_deploy runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}" steps: - name: Slack Workflow Notification diff --git a/.github/workflows/python-style-police.yml b/.github/workflows/python-style-police.yml index 890d2de..7de8a4b 100644 --- a/.github/workflows/python-style-police.yml +++ b/.github/workflows/python-style-police.yml @@ -49,7 +49,7 @@ jobs: tox -e formatcheck slack-workflow-status: - if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }} + if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }} name: Post Workflow Status to Slack needs: - python-style-police diff --git a/.github/workflows/test-python-package.yml b/.github/workflows/test-python-package.yml index 5a8a1cd..fc1c0e9 100644 --- a/.github/workflows/test-python-package.yml +++ b/.github/workflows/test-python-package.yml @@ -53,7 +53,7 @@ jobs: tox slack-workflow-status: - if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }} + if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }} name: Post Workflow Status to Slack needs: - python