Build / Release #168
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: | |
fail-fast: false | |
matrix: | |
include: | |
- runner: macos-12 | |
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@v5 | |
with: | |
python-version: '3.11.5' | |
- name: Setup Python (BuildJet Runner) | |
if: contains(matrix.runner, 'buildjet') | |
uses: gabrielfalcao/pyenv-action@v18 | |
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@v3 | |
with: | |
timeout_minutes: 5 | |
max_attempts: 5 | |
retry_wait_seconds: 120 | |
command: make clean-venv 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' | |
# TODO re-enable when mac11 docker gets more stable | |
if: ${{ false }} | |
run: | | |
brew install docker | |
colima start | |
- name: Community 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: Pro Non-Docker Smoke tests | |
shell: bash | |
# Skip these checks for forks (forks do not have access to the LocalStack Pro API key) | |
if: ${{ ! github.event.pull_request.head.repo.fork }} | |
run: | | |
# create an extension with default parameters (enter all new lines to use defaults) | |
printf "\n\n\n\n\n\n\n\n\n" | LOCALSTACK_API_KEY=${{ secrets.TEST_LOCALSTACK_API_KEY }} DEBUG=1 ./dist-bin/localstack extensions dev new | |
# print the directory output | |
ls -al my-localstack-extension | |
# remove it again | |
rm -rf my-localstack-extension | |
- 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/ | |
# TODO re-enable for mac when mac11 docker gets more stable, and for buildjet when the tests there get more stable | |
if: matrix.os != 'windows' && matrix.os != 'darwin' && matrix.runner != 'buildjet-2vcpu-ubuntu-2204-arm' | |
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) | |
# TODO re-enable for mac when mac11 docker gets more stable, and for buildjet when the tests there get more stable | |
if: matrix.os != 'windows' && matrix.os != 'darwin' && matrix.runner != 'buildjet-2vcpu-ubuntu-2204-arm' && !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 with an API key (legacy) | |
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 | |
# start pro with an auth token and extensions dev mode (see issue #20) | |
LOCALSTACK_AUTH_TOKEN=${{ secrets.TEST_LOCALSTACK_AUTH_TOKEN }} EXTENSION_DEV_MODE=1 ./localstack start -d | |
./localstack wait -t 180 | |
./localstack logs | grep "extension developer mode enabled" | |
./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 | sed 's/.*\s//')" >> $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@v4 | |
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@v4 | |
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@v4 | |
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@v2 | |
with: | |
files: 'builds/*' | |
draft: true | |
token: ${{ secrets.LOCALSTACK_GITHUB_TOKEN }} |