hotfix: fix error when trying to skip ssl verify using envar PHASE_VE… #374
Workflow file for this run
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: Test, Build, Package the Phase CLI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
pytest: | |
name: Run Tests | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python-version: [3.11] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- run: pip install -r dev-requirements.txt | |
- run: pip install pytest | |
- name: Set PYTHONPATH | |
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV | |
- run: pytest tests/*.py | |
extract_version: | |
name: Extract Version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Extract version | |
run: | | |
echo "PHASE_CLI_VERSION=$(grep -oP '(?<=__version__ = ")[^"]*' phase_cli/utils/const.py)" >> $GITHUB_ENV | |
echo "${{ env.PHASE_CLI_VERSION }}" > ./PHASE_CLI_VERSION.txt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: phase-version | |
path: ./PHASE_CLI_VERSION.txt | |
build: | |
name: Build CLI | |
runs-on: ${{ matrix.os }} | |
needs: [pytest, extract_version] | |
strategy: | |
matrix: | |
# ubuntu-20.04 - context: https://github.com/phasehq/cli/issues/94 | |
# macos-13 darwin-amd64 builds (intel) | |
# macos-14 darwin-arm64 builds (apple silicon) | |
# context: https://github.com/actions/runner-images?tab=readme-ov-file#available-images | |
os: [ubuntu-20.04, windows-2022, macos-13, macos-14] | |
python-version: [3.11] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- run: pip install -r requirements.txt | |
- run: pip install pyinstaller | |
- run: pyinstaller --hidden-import _cffi_backend --paths ./phase_cli --name phase phase_cli/main.py | |
- name: Print GLIBC version | |
if: matrix.os == 'ubuntu-20.04' | |
run: ldd --version | |
# Set LC_ALL based on the runner OS for Linux and macOS | |
- name: Set LC_ALL for Linux and macOS | |
run: export LC_ALL=C.UTF-8 | |
if: runner.os != 'Windows' | |
shell: bash | |
# Set LC_ALL for Windows | |
- name: Set LC_ALL for Windows | |
run: echo "LC_ALL=C.UTF-8" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV | |
if: runner.os == 'Windows' | |
shell: pwsh | |
# Download the version file | |
- uses: actions/download-artifact@v4 | |
with: | |
name: phase-version | |
# Set the version environment variable | |
- name: Set VERSION | |
run: echo "PHASE_CLI_VERSION=$(cat PHASE_CLI_VERSION.txt)" >> $GITHUB_ENV | |
shell: bash | |
# Build DEB and RPM packages for Linux | |
- run: | | |
sudo apt-get update | |
sudo apt-get install -y ruby-dev rubygems build-essential | |
sudo gem install --no-document fpm | |
fpm -s dir -t deb -n phase -v ${{ env.PHASE_CLI_VERSION }} dist/phase/=usr/bin/ | |
fpm -s dir -t rpm -n phase -v ${{ env.PHASE_CLI_VERSION }} dist/phase/=usr/bin/ | |
if: matrix.os == 'ubuntu-20.04' | |
shell: bash | |
# Upload DEB and RPM packages | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: phase-deb | |
path: "*.deb" | |
if: matrix.os == 'ubuntu-20.04' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: phase-rpm | |
path: "*.rpm" | |
if: matrix.os == 'ubuntu-20.04' | |
- name: Set artifact name | |
run: | | |
if [[ "${{ matrix.os }}" == "macos-14" ]]; then | |
echo "ARTIFACT_NAME=${{ runner.os }}-arm64-binary" >> $GITHUB_ENV | |
elif [[ "${{ matrix.os }}" == "macos-13" ]]; then | |
echo "ARTIFACT_NAME=${{ runner.os }}-amd64-binary" >> $GITHUB_ENV | |
else | |
echo "ARTIFACT_NAME=${{ runner.os }}-binary" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: dist/phase* | |
build_arm: | |
name: Build CLI for ARM64 | |
runs-on: self-hosted | |
container: | |
image: python:3.11.0-bullseye | |
needs: [pytest, extract_version] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Environment | |
run: | | |
python --version | |
pip install -r requirements.txt | |
pip install pyinstaller | |
- name: Build with PyInstaller | |
run: pyinstaller --hidden-import _cffi_backend --paths ./phase_cli --name phase phase_cli/main.py | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Linux-binary-arm64 | |
path: dist/phase* | |
build_apk: | |
name: Build CLI (alpine-latest, 3.11) | |
runs-on: ubuntu-20.04 | |
needs: [pytest, extract_version] | |
container: | |
image: python:3.11-alpine | |
steps: | |
- uses: actions/checkout@v2 | |
- run: apk add --update --no-cache python3 python3-dev build-base | |
- run: python3 -m ensurepip | |
- run: pip3 install --no-cache --upgrade pip setuptools | |
- run: pip install -r requirements.txt | |
- run: pip install pyinstaller | |
- run: pyinstaller --hidden-import _cffi_backend --paths ./phase_cli --name phase phase_cli/main.py | |
- run: apk add alpine-sdk | |
- run: adduser -G abuild -g "Alpine Package Builder" -s /bin/ash -D builder | |
- run: mkdir /home/builder/package | |
- run: chown builder /home/builder/package | |
- run: apk add --no-cache sudo | |
- run: | | |
echo "builder ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers | |
ls ./dist/phase | |
cp -r ./dist/phase/* /home/builder/package/ | |
cp ./APKBUILD /home/builder/package | |
cd /home/builder/package | |
sudo -u builder abuild-keygen -a -i -n | |
sudo -u builder abuild checksum | |
sudo -u builder abuild -r | |
shell: sh | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: phase-apk | |
path: /home/builder/packages/builder/x86_64/*.apk | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: phase-alpine-build | |
path: ./dist/phase | |
Build_and_push_docker: | |
name: Build & Release - Docker | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
needs: [build, build_apk] | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download phase-version artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: phase-version | |
path: phase-version | |
- name: Set VERSION from file | |
run: echo "VERSION=$(cat ./phase-version/PHASE_CLI_VERSION.txt | tr -d '\r')" >> $GITHUB_ENV | |
- name: Download phase-alpine-build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: phase-alpine-build | |
path: dist | |
- run: docker build -t phase-cli:${{ env.VERSION }} . | |
- name: Push to Docker Hub | |
run: | | |
echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin | |
docker tag phase-cli:${{ env.VERSION }} phasehq/cli:${{ env.VERSION }} | |
docker push phasehq/cli:${{ env.VERSION }} | |
docker tag phase-cli:${{ env.VERSION }} phasehq/cli:latest | |
docker push phasehq/cli:latest | |
Pull_and_test_docker_image: | |
name: Test - CLI - Docker | |
needs: Build_and_push_docker | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Download phase-version artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: phase-version | |
path: phase-version | |
- name: Set VERSION from file | |
run: echo "VERSION=$(cat ./phase-version/PHASE_CLI_VERSION.txt | tr -d '\r')" >> $GITHUB_ENV | |
# Pull and test the versioned Docker image | |
- run: docker pull phasehq/cli:${{ env.VERSION }} | |
- run: docker run phasehq/cli:${{ env.VERSION }} phase -h | |
- run: docker run phasehq/cli:${{ env.VERSION }} phase -v | |
# Pull and test the latest Docker image | |
- run: docker pull phasehq/cli:latest | |
- run: docker run phasehq/cli:latest phase -h | |
- run: docker run phasehq/cli:latest phase -v | |
attach-assets: | |
name: Package assets | |
needs: [build, build_apk, build_arm] | |
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_*/ |