Skip to content

Commit

Permalink
Reorganize release script for two projects (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpacifici committed Oct 11, 2023
1 parent 5069ad1 commit ee921dc
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 18 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build-jsonish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# TODO: This one and sentry_jsonnet are almost the same.
# A reusable flow would help.
name: build sentry_jsonish

on:
push:
branches:
- main
- release-jsonish/**

jobs:
dist:
name: Create wheel and source distribution for sentry-jsonish
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: "Prepare artifacts"
working-directory: ./sentry_jsonish
run: |
pip install wheel
pip install build
python -m build --wheel
- uses: actions/upload-artifact@v3.1.1
with:
name: ${{ github.sha }}
path: sentry_jsonish/dist/*
30 changes: 30 additions & 0 deletions .github/workflows/build-jsonnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# TODO: This one and sentry_jsonish are almost the same.
# A reusable flow would help.
name: build sentry_jsonnet

on:
push:
branches:
- main
- release-jsonnet/**

jobs:
dist:
name: Create wheel and source distribution for sentry-jsonnet
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: "Prepare artifacts"
working-directory: ./sentry_jsonnet
run: |
pip install wheel
pip install build
python -m build --wheel
- uses: actions/upload-artifact@v3.1.1
with:
name: ${{ github.sha }}
path: sentry_jsonnet/dist/*
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Release binding
# TODO: This one and sentry_jsonnet are almost the same.
# A reusable flow would help.
name: Release sentry_jsonish

on:
workflow_dispatch:
Expand All @@ -19,10 +21,12 @@ jobs:
with:
token: ${{ secrets.GH_RELEASE_PAT }}
fetch-depth: 0

- name: Prepare release
uses: getsentry/action-prepare-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
with:
version: ${{ github.event.inputs.version }}
force: ${{ github.event.inputs.force }}
path: sentry_jsonish
32 changes: 32 additions & 0 deletions .github/workflows/release-jsonnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# TODO: This one and sentry_jsonish are almost the same.
# A reusable flow would help.
name: Release sentry_jsonnet

on:
workflow_dispatch:
inputs:
version:
description: Version to release
required: true
force:
description: Force a release even when there are release-blockers (optional)
required: false

jobs:
release:
runs-on: ubuntu-latest
name: "Release a new version"
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_RELEASE_PAT }}
fetch-depth: 0

- name: Prepare release
uses: getsentry/action-prepare-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
with:
version: ${{ github.event.inputs.version }}
force: ${{ github.event.inputs.force }}
path: sentry_jsonnet
20 changes: 20 additions & 0 deletions sbin/bump-version-jsonish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -eux

OLD_VERSION="${1}"
NEW_VERSION="${2}"

echo "Current version: $OLD_VERSION"
echo "Bumping version: $NEW_VERSION"

function replace() {
! grep "$2" $3
perl -i -pe "s/$1/$2/g" $3
grep "$2" $3 # verify that replacement was successful
}

# TODO: The only difference between this and the jsonnet
# version is the path of pyproject. Making that a parameter
# would be trivial but I would have to look into craft details
# to find a way to hardcode a parameter.
replace "version = \"[0-9.]+\"" "version = \"$NEW_VERSION\"" sentry_jsonish/pyproject.toml
20 changes: 20 additions & 0 deletions sbin/bump-version-jsonnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -eux

OLD_VERSION="${1}"
NEW_VERSION="${2}"

echo "Current version: $OLD_VERSION"
echo "Bumping version: $NEW_VERSION"

function replace() {
! grep "$2" $3
perl -i -pe "s/$1/$2/g" $3
grep "$2" $3 # verify that replacement was successful
}

# TODO: The only difference between this and the jsonish
# version is the path of pyproject. Making that a parameter
# would be trivial but I would have to look into craft details
# to find a way to hardcode a parameter.
replace "version = \"[0-9.]+\"" "version = \"$NEW_VERSION\"" sentry_jsonnet/pyproject.toml
16 changes: 0 additions & 16 deletions sbin/bump-version.sh

This file was deleted.

4 changes: 3 additions & 1 deletion .craft.yml → sentry_jsonish/.craft.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
minVersion: 0.34.1
github:
owner: getsentry
repo: jsonnet-libs
changelogPolicy: auto
preReleaseCommand: bash sbin/bump-version.sh
preReleaseCommand: bash sbin/bump-version-jsonish.sh
releaseBranchPrefix: release-sentry-jsonish
targets:
- name: github
- name: pypi
Expand Down
12 changes: 12 additions & 0 deletions sentry_jsonnet/.craft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
minVersion: 0.34.1
github:
owner: getsentry
repo: jsonnet-libs
changelogPolicy: auto
preReleaseCommand: bash sbin/bump-version-jsonnet.sh
releaseBranchPrefix: release-sentry-jsonnet
targets:
- name: pypi
- name: sentry-pypi
internalPypiRepo: getsentry/pypi

0 comments on commit ee921dc

Please sign in to comment.