Skip to content

Commit

Permalink
Fix for static linking of Linux binary (#27)
Browse files Browse the repository at this point in the history
* Use python version from the container in CD
* Upgrade dependencies
* Update the changelog
  • Loading branch information
mlech-reef authored Sep 24, 2021
1 parent 5949c90 commit 844e58e
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 66 deletions.
48 changes: 36 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,38 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-pybindings:
runs-on: ${{ matrix.os }}
build-linux-pybindings:
runs-on: ubuntu-latest
container:
image: python:3.9 # can not use ${{ env.PYTHON_DEFAULT_VERSION }} here
env:
DEBIAN_FRONTEND: noninteractive
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies
working-directory: python-bindings
run: |
apt-get -y update
apt-get -y install patchelf
make deps
- name: Build python bindings
id: build
working-directory: python-bindings
run: |
make build
- name: Upload python bindings
uses: actions/upload-artifact@v2
with:
name: py-terraform-provider-b2-linux
path: python-bindings/dist/py-terraform-provider-b2
if-no-files-found: error
retention-days: 1
build-macos-pybindings:
runs-on: macos-10.15
outputs:
version: ${{ steps.build.outputs.version }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-10.15]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
Expand All @@ -36,12 +60,12 @@ jobs:
- name: Upload python bindings
uses: actions/upload-artifact@v2
with:
name: py-terraform-provider-b2-${{ runner.os }}
name: py-terraform-provider-b2-darwin
path: python-bindings/dist/py-terraform-provider-b2
if-no-files-found: error
retention-days: 1
build-and-deploy:
needs: build-pybindings
needs: [build-linux-pybindings, build-macos-pybindings]
env:
NOPYBINDINGS: 1 # do not build python buildings
runs-on: ubuntu-latest
Expand All @@ -61,17 +85,17 @@ jobs:
- name: Download python bindings for all OSes
uses: actions/download-artifact@v2
with:
path: python-bindings/dist/
path: python-bindings/dist/artifacts/
- name: Postprocess python bindings
working-directory: python-bindings/dist
run: |
mv py-terraform-provider-b2-Linux/py-terraform-provider-b2 py-terraform-provider-b2-linux
mv py-terraform-provider-b2-macOS/py-terraform-provider-b2 py-terraform-provider-b2-darwin
mv artifacts/py-terraform-provider-b2-linux/py-terraform-provider-b2 py-terraform-provider-b2-linux
mv artifacts/py-terraform-provider-b2-darwin/py-terraform-provider-b2 py-terraform-provider-b2-darwin
- name: Read the Changelog
id: read-changelog
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ needs.build-pybindings.outputs.version }}
version: ${{ needs.build-linux-pybindings.outputs.version }}
- name: Import GPG key
id: import_gpg
uses: paultyng/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
* Fix for static linking of Python bindings for Linux (CD uses python container)

## [0.6.1] - 2021-09-01

### Changed
Expand Down
8 changes: 4 additions & 4 deletions python-bindings/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ clean:
@rm -rf build dist ${EGG_INFO}

build:
@pyinstaller --log-level WARN --onefile ${SPEC}
@pyinstaller --onefile ${SPEC}
ifeq ($(UNAME_),Linux)
@mv dist/py-terraform-provider-b2 dist/py-terraform-provider-b2-linked
@staticx dist/py-terraform-provider-b2-linked dist/py-terraform-provider-b2
@rm dist/py-terraform-provider-b2-linked
@mv -f dist/py-terraform-provider-b2 dist/py-terraform-provider-b2-linked
@staticx --strip --loglevel INFO dist/py-terraform-provider-b2-linked dist/py-terraform-provider-b2
@rm -f dist/py-terraform-provider-b2-linked
endif
ifneq ($(origin CI), undefined)
@echo "::set-output name=version::$(subst refs/tags/v,,${GITHUB_REF})"
Expand Down
4 changes: 2 additions & 2 deletions tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/Backblaze/terraform-provider-b2/tools
go 1.16

require (
github.com/golangci/golangci-lint v1.42.0
github.com/hashicorp/terraform-plugin-docs v0.4.0
github.com/golangci/golangci-lint v1.42.1
github.com/hashicorp/terraform-plugin-docs v0.5.0
)
Loading

0 comments on commit 844e58e

Please sign in to comment.