Skip to content

Feat gh actions workflow improvements #30

Feat gh actions workflow improvements

Feat gh actions workflow improvements #30

Workflow file for this run

name: Test, Build, Package the Phase CLI
on:
pull_request:
push:
branches:
- main
release:
types: [created]
permissions:
contents: write
pull-requests: write
jobs:
pytest:
uses: ./.github/workflows/pytest.yml
with:
python_version: '3.11'
version:
uses: ./.github/workflows/version.yml
build:
needs: [pytest, version]
uses: ./.github/workflows/build.yml
with:
python_version: '3.11'
docker:
if: github.event_name == 'release' && github.event.action == 'created'
needs: [version]
uses: ./.github/workflows/docker.yml
with:
version: ${{ needs.version.outputs.version }}
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
pypi:
#if: github.event_name == 'release' && github.event.action == 'created'
needs: [version]
uses: ./.github/workflows/pypi.yml
with:
version: ${{ needs.version.outputs.version }}
secrets:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
attach-assets:
name: Package assets
needs: [build]
runs-on: ubuntu-20.04
steps:
# Download all the artifacts from the build jobs
- name: Download all artifacts
uses: actions/download-artifact@v4
# # Debug: List the content of the current directory
# - name: Debug - List contents of artifacts directory
# run: find . -type f
# Extract version from the file
- name: Set VERSION from file
run: echo "VERSION=$(cat ./phase-version/PHASE_CLI_VERSION.txt | tr -d '\r')" >> $GITHUB_ENV
# Process assets: Rename, calculate sha256, and move them to the release directory
- name: Process assets
run: |
mkdir phase_cli_release_$VERSION
# For DEB
mv phase-deb/*.deb phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.deb
sha256sum phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.deb > phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.deb.sha256
# For RPM
mv phase-rpm/*.rpm phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.rpm
sha256sum phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.rpm > phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.rpm.sha256
# For Linux
ZIPNAME="phase_cli_linux_amd64_$VERSION.zip"
zip -r "$ZIPNAME" Linux-binary/phase/ Linux-binary/phase/_internal
mv "$ZIPNAME" phase_cli_release_$VERSION/
sha256sum phase_cli_release_$VERSION/"$ZIPNAME" > phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.sha256
# For Windows
ZIPNAME="phase_cli_windows_amd64_$VERSION.zip"
zip -r "$ZIPNAME" Windows-binary/phase/ Windows-binary/phase/_internal
mv "$ZIPNAME" phase_cli_release_$VERSION/
sha256sum phase_cli_release_$VERSION/"$ZIPNAME" > phase_cli_release_$VERSION/phase_cli_windows_amd64_$VERSION.sha256
# For MacOS Intel build
ZIPNAME="phase_cli_macos_amd64_$VERSION.zip"
zip -r "$ZIPNAME" macOS-amd64-binary/phase/ macOS-binary/phase/_internal
mv "$ZIPNAME" phase_cli_release_$VERSION/
sha256sum phase_cli_release_$VERSION/"$ZIPNAME" > phase_cli_release_$VERSION/phase_cli_macos_amd64_$VERSION.sha256
# For MacOS Apple silicon build
ZIPNAME="phase_cli_macos_arm64_$VERSION.zip"
zip -r "$ZIPNAME" macOS-arm64-binary/phase/ macOS-binary/phase/_internal
mv "$ZIPNAME" phase_cli_release_$VERSION/
sha256sum phase_cli_release_$VERSION/"$ZIPNAME" > phase_cli_release_$VERSION/phase_cli_macos_arm64_$VERSION.sha256
# For Alpine build
ZIPNAME="phase_cli_alpine_linux_amd64_$VERSION.zip"
zip -r "$ZIPNAME" phase-alpine-build/phase phase-alpine-build/_internal
mv "$ZIPNAME" phase_cli_release_$VERSION/
sha256sum phase_cli_release_$VERSION/"$ZIPNAME" > phase_cli_release_$VERSION/phase_cli_alpine_linux_amd64_$VERSION.sha256
# For Alpine package
mv phase-apk/*.apk phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.apk
sha256sum phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.apk > phase_cli_release_$VERSION/phase_cli_linux_amd64_$VERSION.apk.sha256
# Process assets for ARM64
- name: Process ARM64 assets
run: |
mkdir -p phase_cli_release_$VERSION/Linux-binary/phase/
mv Linux-binary-arm64/phase/* phase_cli_release_$VERSION/Linux-binary/phase/
# Adjust the ZIPNAME and paths for ARM64 binary
ZIPNAME="phase_cli_linux_arm64_$VERSION.zip"
zip -r "$ZIPNAME" phase_cli_release_$VERSION/Linux-binary/phase/ phase_cli_release_$VERSION/Linux-binary/phase/_internal
mv "$ZIPNAME" phase_cli_release_$VERSION/
sha256sum phase_cli_release_$VERSION/"$ZIPNAME" > phase_cli_release_$VERSION/phase_cli_linux_arm64_$VERSION.sha256
# Cleanup the ARM64 binary folder
rm -rf Linux-binary
# Upload the entire release directory as a single artifact
- uses: actions/upload-artifact@v4
with:
name: phase-cli-release
path: ./phase_cli_release_*/