add native Apple Silicon / M1 binaries (#12) #62
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: Build / Release | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- runner: macos-11 | |
os: darwin | |
arch: amd64 | |
- runner: macos-13-xlarge | |
os: darwin | |
arch: arm64 | |
- runner: windows-2019 | |
os: windows | |
arch: amd64 | |
- runner: ubuntu-20.04 | |
os: linux | |
arch: amd64 | |
- runner: buildjet-2vcpu-ubuntu-2204-arm | |
os: linux | |
arch: arm64 | |
runs-on: ${{ matrix.runner }} | |
outputs: | |
cli_version: ${{ steps.cli_version.outputs.cli_version }} | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v4 | |
- name: Setup Python (GitHub Runner) | |
if: ${{ !contains(matrix.runner, 'buildjet') }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11.5' | |
- name: Setup Python (BuildJet Runner) | |
if: contains(matrix.runner, 'buildjet') | |
uses: gabrielfalcao/pyenv-action@v16 | |
with: | |
default: '3.11.4' | |
# Add a retry to avoid issues when this action is running | |
# right after the package is published on PyPi | |
# (and might not be distributed in the CDN yet) | |
- name: Create virtual environment | |
uses: nick-fields/retry@v2 | |
with: | |
timeout_minutes: 5 | |
max_attempts: 5 | |
retry_wait_seconds: 120 | |
command: make venv | |
- name: Build using pyinstaller | |
shell: bash | |
run: make clean all | |
- name: Setup Docker on MacOS | |
# Install docker and start Colima on MacOS (except it's the large runner) | |
# GitHub xlarge MacOS runner cannot run Docker containers: | |
# - https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/ | |
if: matrix.os == 'darwin' && matrix.runner != 'macos-13-xlarge' | |
run: | | |
brew install docker | |
colima start | |
- name: Non-Docker Smoke tests | |
shell: bash | |
run: | | |
ls dist-bin/ | |
cd dist-bin | |
# show the help | |
./localstack --help | |
# show the config | |
./localstack config show | |
- name: Community Docker Smoke tests (Linux, MacOS) | |
shell: bash | |
# GitHub Windows and xlarge MacOS runner cannot run Docker containers: | |
# - https://github.com/orgs/community/discussions/25491 | |
# - https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/ | |
if: matrix.os != 'windows' && matrix.runner != 'macos-13-xlarge' | |
run: | | |
# Pull images to avoid making smoke tests vulnerable to system behavior (docker pull speed) | |
docker pull localstack/localstack | |
cd dist-bin | |
# start community | |
./localstack start -d | |
./localstack wait -t 180 | |
./localstack status services --format plain | |
./localstack status services --format plain | grep "s3=available" | |
./localstack stop | |
- name: Pro Docker Smoke tests (Linux, MacOS) | |
shell: bash | |
# GitHub Windows and xlarge MacOS runner cannot run Docker containers: | |
# - https://github.com/orgs/community/discussions/25491 | |
# - https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/ | |
# Skip these checks for forks (forks do not have access to the LocalStack Pro API key) | |
if: matrix.os != 'windows' && matrix.runner != 'macos-13-xlarge' && !github.event.pull_request.head.repo.fork | |
run: | | |
# Pull images to avoid making smoke tests vulnerable to system behavior (docker pull speed) | |
docker pull localstack/localstack-pro | |
cd dist-bin | |
# start pro | |
LOCALSTACK_API_KEY=${{ secrets.TEST_LOCALSTACK_API_KEY }} ./localstack start -d | |
./localstack wait -t 180 | |
./localstack status services --format plain | |
./localstack status services --format plain | grep "xray=available" | |
./localstack stop | |
- name: Set CLI version output | |
id: cli_version | |
shell: bash | |
run: | | |
dist-bin/localstack --version | |
echo "cli_version=$(dist-bin/localstack --version)" >> $GITHUB_OUTPUT | |
- name: Archive distribution (Linux, MacOS) | |
if: matrix.os != 'windows' | |
run: | | |
cd dist-bin/ | |
tar -czf ${{github.event.repository.name}}-${{steps.cli_version.outputs.cli_version}}-${{ matrix.os }}-${{ matrix.arch }}-onefile.tar.gz localstack | |
rm localstack | |
cd ../dist-dir/ | |
tar -czf ${{github.event.repository.name}}-${{steps.cli_version.outputs.cli_version}}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz localstack | |
rm -r localstack | |
- name: Archive distribution (Windows) | |
if: matrix.os == 'windows' | |
run: | | |
cd dist-bin/ | |
Compress-Archive localstack.exe ${{github.event.repository.name}}-${{steps.cli_version.outputs.cli_version}}-${{ matrix.os }}-${{ matrix.arch }}-onefile.zip | |
rm localstack.exe | |
cd ../dist-dir/ | |
Compress-Archive localstack ${{github.event.repository.name}}-${{steps.cli_version.outputs.cli_version}}-${{ matrix.os }}-${{ matrix.arch }}.zip | |
rm -r localstack | |
- name: Upload binary artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{github.event.repository.name}}-${{steps.cli_version.outputs.cli_version}}-${{ matrix.os }}-${{ matrix.arch }}-onefile | |
path: 'dist-bin/*' | |
- name: Upload folder artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{github.event.repository.name}}-${{steps.cli_version.outputs.cli_version}}-${{ matrix.os }}-${{ matrix.arch }} | |
path: 'dist-dir/*' | |
release: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: | |
- build | |
permissions: | |
contents: write | |
steps: | |
- name: Download Builds | |
uses: actions/download-artifact@v3 | |
with: | |
path: builds | |
- name: Generate Checksums | |
run: | | |
# move all files from the builds subdirectories to the builds root folder | |
find ./builds/ -type f -print0 | xargs -0 mv -t ./builds/ | |
# remove all (empty) subdirectories | |
find ./builds/ -mindepth 1 -maxdepth 1 -type d -print0 | xargs -r0 rm -R | |
# generate the checksums | |
cd builds | |
sha256sum *.{tar.gz,zip} > ${{github.event.repository.name}}-${{needs.build.outputs.cli_version}}-checksums.txt | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: 'builds/*' | |
draft: true | |
token: ${{ secrets.LOCALSTACK_GITHUB_TOKEN }} |