Skip to content

Commit

Permalink
fix: move to upstream semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jan 4, 2022
1 parent f5ef6e2 commit b742a01
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 33 deletions.
43 changes: 25 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,40 +238,47 @@ jobs:
- docker-image
- pre-commit
- tensorflow
concurrency: release
steps:
- uses: tibdex/github-app-token@v1
if: ${{ github.event_name != 'pull_request' }}
id: generate_token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- uses: actions/checkout@v2
if: ${{ github.event_name != 'pull_request' }}
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}

- uses: actions/checkout@v2
if: ${{ github.event_name == 'pull_request' }}
- uses: cachix/install-nix-action@v16
with:
fetch-depth: 0
nix_path: nixpkgs=channel:nixos-unstable-small

- run: git config --global user.name "github-actions"
- run: git config --global user.email "[email protected]"
- uses: cachix/cachix-action@v10
with:
name: stupidb
extraPullNames: nix-community,poetry2nix

- uses: actions/setup-python@v2
- name: setup nodejs
uses: actions/setup-node@v2
with:
python-version: "3.x"
node-version: 16

- run: pip install poetry python-semantic-release
- name: run semantic-release
run: |
set -euo pipefail
- run: semantic-release publish --verbosity=DEBUG
if: ${{ github.event_name != 'pull_request' }}
npx \
-p semantic-release \
-p "@semantic-release/commit-analyzer" \
-p "@semantic-release/release-notes-generator" \
-p "@semantic-release/changelog" \
-p "@semantic-release/github" \
-p "@semantic-release/exec"\
-p "@semantic-release/git" \
semantic-release \
--ci
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

- run: semantic-release publish --noop --verbosity=DEBUG
if: ${{ github.event_name == 'pull_request' }}
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
GIT_CREDENTIALS: ${{ steps.generate_token.outputs.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogTitle": "# Release Notes"
}
],
[
"@semantic-release/exec",
{
"verifyConditionsCmd": "ci/release/verify.sh",
"prepareCmd": "ci/release/prepare.sh ${nextRelease.version}",
"publishCmd": "ci/release/publish.sh"
}
],
[
"@semantic-release/github",
{
"assets": ["dist/*.whl"]
}
],
[
"@semantic-release/git",
{
"assets": ["pyproject.toml", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version}"
}
]
]
}
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Changelog

<!--next-version-placeholder-->
# Release Notes

## v0.7.1 (2021-12-24)
### Documentation
Expand Down
11 changes: 11 additions & 0 deletions ci/release/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env nix-shell
#!nix-shell --pure -p poetry -i bash
# shellcheck shell=bash

set -euo pipefail

# set version
poetry version "$1"

# build artifacts
poetry build
7 changes: 7 additions & 0 deletions ci/release/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env nix-shell
#!nix-shell --pure --keep POETRY_PYPI_TOKEN_PYPI -p poetry -i bash
# shellcheck shell=bash

set -euo pipefail

poetry publish
15 changes: 15 additions & 0 deletions ci/release/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env nix-shell
#!nix-shell --pure --keep POETRY_PYPI_TOKEN_PYPI -p poetry -p git -i bash
# shellcheck shell=bash

set -euo pipefail

# verify TOML is sane
poetry check

# verify that the lock file is up to date
poetry lock --no-update
git diff --exit-code poetry.lock

# verify that we have a token available to push to pypi using set -u
: "${POETRY_PYPI_TOKEN_PYPI}"
14 changes: 13 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,26 @@
entry = "${pkgs.protoletariatDevEnv}/bin/mypy";
types = [ "python" ];
};

shellcheck = {
enable = true;
entry = "${pkgs.shellcheck}/bin/shellcheck";
files = "\\.sh$";
types_or = [ "file" ];
};

shfmt = {
enable = true;
entry = "${pkgs.shfmt}/bin/shfmt -i 2 -sr -d -s -l";
files = "\\.sh$";
};
};
};
};

devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
buf
commitizen
grpc
poetry
prettierTOML
Expand Down
11 changes: 0 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ types-protobuf = "^3.18.1"
[tool.poetry.scripts]
protol = "protoletariat.__main__:main"

[tool.semantic_release]
version_toml = "pyproject.toml:tool.poetry.version"
version_variable = ["protoletariat/__init__.py:__version__"]
branch = "main"
upload_to_pypi = true
upload_to_release = true
build_command = "poetry build"
commit_subject = "chore(release): {version}"
commit_author = "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
changelog_file = "CHANGELOG.md"

[tool.pytest.ini_options]
xfail_strict = true
addopts = [
Expand Down

0 comments on commit b742a01

Please sign in to comment.