Skip to content

Commit

Permalink
ci: Improve release GHA by using semantic-release (#77)
Browse files Browse the repository at this point in the history
This PR adds button-triggered GHA doing "semantic release". In other
words, the semantic release tool should go through history of the repo
and generate proper version number and release notes. With those, it
should create GH release of the new version, create wheel file and
upload it to PyPi.

based on:

https://github.com/t0mk/equinix-sdk-go/blob/main/.github/workflows/release.yaml
  • Loading branch information
t0mk authored Feb 9, 2024
1 parent cdef172 commit ec820a3
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 7 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release Package to PyPI
name: Semantic Release to GitHub and PyPI
on:
release:
types: [published]
workflow_dispatch: null

env:
PACKAGE_DIR: equinix_metal
DIST_DIR: equinix_metal/dist
Expand All @@ -14,6 +14,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -25,6 +27,26 @@ jobs:
run: |
python -m pip install --upgrade build
- name: Install pyaml for patching script
working-directory: ${{ env.PACKAGE_DIR }}
run: |
python -m pip install pyaml
- name: Do GitHub release
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 19.0.5
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: equinix-labs@auto-commit-workflow
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: equinix-labs@auto-commit-workflow
GIT_COMMITTER_EMAIL: [email protected]

- name: Build package
working-directory: ${{ env.PACKAGE_DIR }}
run: |
Expand All @@ -35,6 +57,4 @@ jobs:
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: ${{ env.DIST_DIR }}


packages-dir: ${{ env.DIST_DIR }}
41 changes: 41 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"branches": [
"main"
],
"ci": false,
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
"labels": false,
"releasedLabels": false
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "echo -n '${nextRelease.version}' > version && make generate"
}
],
[
"@semantic-release/git",
{
"message": "ci: regenerate code for version ${nextRelease.version} triggered by ${process.env.RELEASE_REQUESTER}",
"assets": ["."]
}
]
]
}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PACKAGE_VERSION=0.6.0
VERSION_FILE=version
PACKAGE_VERSION := $(shell cat ${VERSION_FILE})

SPEC_PATCHED_FILE=./metal_openapi.fixed.yaml
OPENAPI_CODEGEN_TAG=v7.0.0
Expand Down
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.6.0

0 comments on commit ec820a3

Please sign in to comment.