Skip to content

Commit

Permalink
Merge pull request #16 from netboxlabs/feat/OBS-392_semantic_release
Browse files Browse the repository at this point in the history
ci: OBS-392 Semantic release bare bones for monorepo.
  • Loading branch information
mfiedorowicz authored Feb 13, 2024
2 parents 31cc037 + f4d6993 commit c0a51f1
Show file tree
Hide file tree
Showing 11 changed files with 14,094 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/python-netbox-plugin-lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Netbox plugin - lint"
name: "Python Netbox plugin - lint"
on:
workflow_dispatch:
push:
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/python-netbox-plugin-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Python Netbox plugin - Release"
on:
workflow_dispatch:
push:
branches: [release]
paths:
- "diode-netbox-plugin/**"
env:
GH_TOKEN: ${{ secrets.ORB_CI_GH_TOKEN }}
SEMANTIC_RELEASE_PACKAGE: ${{ github.repository }}
APP_DIR: diode-netbox-plugin

jobs:
get-next-version:
uses: netboxlabs/diode/.github/workflows/reusable_semantic_release_get_next_version.yaml@develop
with:
# passed vars need hard coding - https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations
app_name: diode-netbox-plugin
app_dir: diode-netbox-plugin
secrets: inherit

build:
name: Build
needs: [get-next-version]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.APP_DIR }}
env:
BUILD_VERSION: ${{ needs.get-next-version.outputs.new-release-version }}
BUILD_TRACK: release
BUILD_COMMIT: ${{ needs.get-next-version.outputs.short-sha }}
steps:
- uses: actions/checkout@v3
#
# do the build and inject versions here
#
# - name: Upload Github build artifact
# uses: actions/upload-artifact@v4
# with:
# name: build-production.zip
# path: services/controlplane/signup-ui/build-production.zip
# retention-days: 1
# if-no-files-found: error

semantic-release:
uses: netboxlabs/diode/.github/workflows/reusable_semantic_release.yaml@develop
needs: [build]
with:
app_dir: diode-netbox-plugin
secrets: inherit

# upload to Docker hub / GHCR / PyPi here
53 changes: 53 additions & 0 deletions .github/workflows/python-sdk-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Python SDK - Release"
on:
workflow_dispatch:
push:
branches: [release]
paths:
- "diode-sdk-python/**"
env:
GH_TOKEN: ${{ secrets.ORB_CI_GH_TOKEN }}
SEMANTIC_RELEASE_PACKAGE: ${{ github.repository }}
APP_DIR: diode-sdk-python

jobs:
get-next-version:
uses: netboxlabs/diode/.github/workflows/reusable_semantic_release_get_next_version.yaml@develop
with:
# passed vars need hard coding - https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations
app_name: diode-sdk-python
app_dir: diode-sdk-python
secrets: inherit

build:
name: Build
needs: [get-next-version]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.APP_DIR }}
env:
BUILD_VERSION: ${{ needs.get-next-version.outputs.new-release-version }}
BUILD_TRACK: release
BUILD_COMMIT: ${{ needs.get-next-version.outputs.short-sha }}
steps:
- uses: actions/checkout@v3
#
# do the build and inject versions here
#
# - name: Upload Github build artifact
# uses: actions/upload-artifact@v4
# with:
# name: build-production.zip
# path: services/controlplane/signup-ui/build-production.zip
# retention-days: 1
# if-no-files-found: error

semantic-release:
uses: netboxlabs/diode/.github/workflows/reusable_semantic_release.yaml@develop
needs: [build]
with:
app_dir: diode-sdk-python
secrets: inherit

# upload to Docker hub / GHCR / PyPi here
30 changes: 30 additions & 0 deletions .github/workflows/reusable_semantic_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Reusable - Semantic Release - Release
on:
workflow_call:
inputs:
app_dir:
type: string
required: true

env:
GH_TOKEN: ${{ secrets.ORB_CI_GH_TOKEN }}
SLACK_SEMANTIC_RELEASE_WEBHOOK: ${{ secrets.SLACK_OBSERVABILITY_RELEASE_WEBHOOK }}

jobs:
semantic-release:
name: Semantic release
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.app_dir }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "21.4.0"
- name: setup semantic-release
run: npm i
- name: Release
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_OBSERVABILITY_RELEASE_WEBHOOK }}
run: npx semantic-release -e semantic-release-monorepo --debug
61 changes: 61 additions & 0 deletions .github/workflows/reusable_semantic_release_get_next_version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Reusable - Semantic Release - Get Next Version
on:
workflow_call:
inputs:
app_name:
type: string
required: true
app_dir:
type: string
required: true
outputs:
new-release-published:
value: ${{ jobs.get-next-version.outputs.new-release-published }}
new-release-version:
value: ${{ jobs.get-next-version.outputs.new-release-version }}
short-sha:
value: ${{ jobs.get-next-version.outputs.short-sha }}

env:
GH_TOKEN: ${{ secrets.ORB_CI_GH_TOKEN }}
SLACK_SEMANTIC_RELEASE_WEBHOOK: ${{ secrets.SLACK_OBSERVABILITY_RELEASE_WEBHOOK }}

jobs:
get-next-version:
name: Semantic release get next version
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.app_dir }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: setup semantic-release
run: npm i
- name: release dry-run
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_OBSERVABILITY_RELEASE_WEBHOOK }}
run: npx semantic-release -e semantic-release-monorepo --debug --dry-run
id: get-next-version
- name: Set short sha output
id: short-sha
run: echo "::set-output name=short-sha::${GITHUB_SHA::7}"
- name: Set release version
id: release-version
run: |
echo "::set-output name=release-version::`echo ${{ steps.get-next-version.outputs.new-release-version }} | sed 's/${{ inputs.app_name }}-v//g'`"
outputs:
new-release-published: ${{ steps.get-next-version.outputs.new-release-published }}
new-release-version: ${{ steps.release-version.outputs.release-version }}
short-sha: ${{ steps.short-sha.outputs.short-sha }}

confirm-version:
name: Next version ${{ needs.get-next-version.outputs.new-release-version }}
runs-on: ubuntu-latest
needs: get-next-version
if: needs.get-next-version.outputs.new-release-published == 'true'
steps:
- uses: actions/checkout@v4
- run: echo "The new release version is ${{ needs.get-next-version.outputs.new-release-version }} commit ${{ needs.get-next-version.outputs.short-sha }}"
36 changes: 36 additions & 0 deletions diode-netbox-plugin/.releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"branches": "release",
"repositoryUrl": "https://github.com/netboxlabs/diode",
"debug": "true",
"extends": "semantic-release-monorepo",
"tagFormat": "diode-netbox-plugin/v${version}",
"plugins": [
["semantic-release-export-data"],
["@semantic-release/commit-analyzer", {
"releaseRules": [
{ "message": "*", "release": "patch"},
{ "message": "fix*", "release": "patch" },
{ "message": "feat*", "release": "minor" },
{ "message": "perf*", "release": "major" }
]
}],
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Semantic Versioning Changelog"
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "release/**"
}
]
}
]
]
}
Loading

0 comments on commit c0a51f1

Please sign in to comment.