Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerelease support #262

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 72 additions & 15 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.build.outputs.version }}
prerelease: ${{ steps.prerelease_check.outputs.prerelease }}
# publish_docker: ${{ steps.prerelease_check.outputs.prerelease == 'false' && secrets.DOCKERHUB_USERNAME != '' }} # doesn't work, hence the workaround
publish_docker: ${{ steps.prerelease_check.outputs.publish_docker }}
steps:
- uses: actions/checkout@v3
- name: Determine if pre-release
id: prerelease_check
run: |
export IS_PRERELEASE=$([[ ${{ github.ref }} =~ [^0-9]$ ]] && echo true || echo false)
echo "prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
export PUBLISH_DOCKER=$([[ $IS_PRERELEASE == 'false' && ${{ secrets.DOCKERHUB_USERNAME }} != '' ]] && echo true || echo false)
echo "publish_docker=$PUBLISH_DOCKER" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install dependencies
Expand All @@ -36,19 +46,19 @@ jobs:
version: ${{ steps.build.outputs.version }}
- name: Create GitHub release and upload the distribution
id: create-release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.build.outputs.version }}
body: ${{ steps.read-changelog.outputs.changes }}
draft: false
prerelease: false
prerelease: ${{ steps.prerelease_check.outputs.prerelease }}
files: ${{ steps.build.outputs.asset_path }}
- name: Upload the distribution to PyPI
if: ${{ env.B2_PYPI_PASSWORD != '' }}
if: ${{ env.B2_PYPI_PASSWORD != '' && steps.prerelease_check.outputs.prerelease == 'false' }}
uses: pypa/[email protected]
with:
user: __token__
password: ${{ env.B2_PYPI_PASSWORD }}
password: ${{ secrets.B2_PYPI_PASSWORD }}
deploy-linux-bundle:
needs: deploy
runs-on: ubuntu-latest
Expand All @@ -57,7 +67,7 @@ jobs:
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
Expand All @@ -76,11 +86,11 @@ jobs:
id: hashes
run: nox -vs make_dist_digest
- name: Upload the bundle to the GitHub release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.deploy.outputs.version }}
draft: false
prerelease: false
prerelease: ${{ needs.deploy.outputs.prerelease }}
files: ${{ steps.sign.outputs.asset_path }}
deploy-windows-bundle:
needs: deploy
Expand All @@ -89,11 +99,11 @@ jobs:
B2_WINDOWS_CODE_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.B2_WINDOWS_CODE_SIGNING_CERTIFICATE_PASSWORD }}
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install dependencies
Expand All @@ -104,21 +114,68 @@ jobs:
run: nox -vs bundle
- name: Import certificate
id: windows_import_cert
if: ${{ env.B2_WINDOWS_CODE_SIGNING_CERTIFICATE != '' }}
uses: timheuer/base64-to-file@v1
with:
fileName: 'cert.pfx'
encodedString: ${{ secrets.B2_WINDOWS_CODE_SIGNING_CERTIFICATE }}
- name: Sign the bundle
if: ${{ env.B2_WINDOWS_CODE_SIGNING_CERTIFICATE != '' }}
id: sign
shell: bash
run: nox -vs sign -- '${{ steps.windows_import_cert.outputs.filePath }}' '${{ env.B2_WINDOWS_CODE_SIGNING_CERTIFICATE_PASSWORD }}'
- name: Generate hashes
id: hashes
run: nox -vs make_dist_digest
- name: Upload the bundle to the GitHub release
uses: softprops/action-gh-release@v1
- name: Create GitHub release and upload the distribution
id: create-release
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.deploy.outputs.version }}
draft: false
prerelease: false
files: ${{ steps.sign.outputs.asset_path }}
prerelease: ${{ needs.deploy.outputs.prerelease }}
files:
${{ steps.sign.outputs.asset_path || steps.bundle.outputs.asset_path }}
deploy-docker:
needs: deploy
if: ${{ needs.deploy.outputs.publish_docker == 'true' }}
runs-on: ubuntu-latest
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install dependencies
run: python -m pip install --upgrade nox pdm
- name: Build Dockerfile
run: nox -vs generate_dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare Docker tags
id: docker_tags_prep
run: |
DOCKER_TAGS=backblazeit/b2:${{ needs.deploy.outputs.version }}
if [ "${{ needs.deploy.outputs.prerelease }}" != "true" ]; then
DOCKER_TAGS="$DOCKER_TAGS,backblazeit/b2:latest"
fi
echo DOCKER_TAGS=$DOCKER_TAGS
echo "docker_tags=$DOCKER_TAGS" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.docker_tags_prep.outputs.docker_tags }}
platforms: linux/amd64,linux/arm64
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: codespell-project/actions-codespell@2391250ab05295bddd51e36a8c6295edb6343b0e
Expand All @@ -37,11 +37,11 @@ jobs:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Install dependencies
Expand All @@ -55,13 +55,13 @@ jobs:
B2_TEST_APPLICATION_KEY_ID: ${{ secrets.B2_TEST_APPLICATION_KEY_ID }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
cache: "pip"
Expand All @@ -88,7 +88,7 @@ jobs:
- os: "windows-latest"
python-version: "pypy3.10"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -112,7 +112,7 @@ jobs:
B2_TEST_APPLICATION_KEY_ID: ${{ secrets.B2_TEST_APPLICATION_KEY_ID }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
Expand All @@ -124,9 +124,9 @@ jobs:
- name: Generate Dockerfile
run: nox -vs generate_dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Build Docker
uses: docker/build-push-action@v5
with:
Expand All @@ -148,7 +148,7 @@ jobs:
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
matrix:
os: [windows-2019, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
Expand Down Expand Up @@ -218,7 +218,7 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
Expand Down
49 changes: 0 additions & 49 deletions .github/workflows/push_docker.yml

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+cd_for_prerelease.infrastructure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for pre-releases in CD.
1 change: 1 addition & 0 deletions changelog.d/+node_20.infrastructure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update to [GitHub Actions using Node 20](https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/).