Skip to content

Commit

Permalink
👷 semantic-release refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Apr 22, 2023
1 parent 0a9ea70 commit aa40930
Show file tree
Hide file tree
Showing 10 changed files with 5,017 additions and 2,181 deletions.
40 changes: 0 additions & 40 deletions .github/helpers/version_check.py

This file was deleted.

6,903 changes: 4,828 additions & 2,075 deletions .github/semantic_release/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions .github/semantic_release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.7",
"semantic-release": "^19.0.5",
"semantic-release-gitmoji": "^1.5.0"
"semantic-release": "^21.0.1",
"semantic-release-gitmoji": "^1.6.4",
"@google/semantic-release-replace-plugin": "^1.2.0"
}
}
93 changes: 93 additions & 0 deletions .github/semantic_release/release_notes.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{{#if compareUrl}}
# [v{{nextRelease.version}}]({{compareUrl}}) ({{datetime "UTC:yyyy-mm-dd"}})
{{else}}
# v{{nextRelease.version}} ({{datetime "UTC:yyyy-mm-dd"}})
{{/if}}

{{#with commits}}

{{#if boom}}
## 💥 Breaking Changes
{{#each boom}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if sparkles}}
## ✨ New Features
{{#each sparkles}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bug}}
## 🐛 Bug Fixes
{{#each bug}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if ambulance}}
## 🚑 Critical Hotfixes
{{#each ambulance}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if lock}}
## 🔒 Security Issues
{{#each lock}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if arrow_up}}
## ⬆️ Dependency Upgrade
{{#each arrow_up}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if memo}}
## 📝️ Documentation
{{#each memo}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if construction_worker}}
## 📝️ CI/CD
{{#each construction_worker}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if white_check_mark}}
## 🧪️ Add / Update / Pass Tests
{{#each white_check_mark}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if test_tube}}
## 🧪️ Add Failing Tests
{{#each test_tube}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if recycle}}
## ♻️Refactoring
{{#each recycle}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if truck}}
## 🚚 Moving/Renaming
{{#each truck}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{/with}}
29 changes: 0 additions & 29 deletions .github/semantic_release/set_version.sh

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
jobs:
pypi-publish:
name: PyPI
if: github.repository_owner == 'juftin'
runs-on: ubuntu-latest
steps:
- name: Check out the repository
Expand Down Expand Up @@ -37,6 +38,7 @@ jobs:

docker-hub-publish:
name: docker-hub
if: github.repository_owner == 'juftin'
runs-on: ubuntu-latest
steps:
- name: Check out the repository
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
- name: Set up Python
Expand All @@ -19,13 +24,10 @@ jobs:
run: |
python -m pip install -q poetry
poetry --version
- name: Install Semantic Release
run: |
npm install --prefix .github/semantic_release
- name: Release
run: npx --prefix .github/semantic_release semantic-release
run: npx --prefix .github/semantic_release/ semantic-release
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
Expand All @@ -34,15 +36,17 @@ jobs:
github-pages-publish:
runs-on: ubuntu-latest
needs: release
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && github.repository_owner == 'juftin'
permissions:
contents: write
steps:
- name: Checkout Latest Changes
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up Python Environment
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Dependencies
Expand All @@ -53,5 +57,9 @@ jobs:
- name: Install Environment
run: |
poetry install --extras all
- name: Set Up GitHub Actions User
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Deploy Documentation Changes
run: poetry run mkdocs gh-deploy --force
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ repos:
exclude: |
(?x)(
docs/cli.md|
PULL_REQUEST_TEMPLATE.md
PULL_REQUEST_TEMPLATE.md|
.github/semantic_release/release_notes.hbs
)
additional_dependencies:
- prettier
Expand Down
74 changes: 74 additions & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const path = require("path");
const fs = require("fs");

const semantic_release_dir = path.resolve(__dirname, ".github/semantic_release");
const release_note_path = path.join(semantic_release_dir, "release_notes.hbs");
const release_note_template = fs.readFileSync(release_note_path, "utf-8");

module.exports = {
branches: [
"main",
"master",
"next",
"next-major",
"+([0-9])?(.{+([0-9]),x}).x",
{
name: "beta",
prerelease: true,
},
{
name: "alpha",
prerelease: true,
},
],
plugins: [
[
"semantic-release-gitmoji",
{
releaseNotes: {
template: release_note_template,
},
},
],
[
"@semantic-release/exec",
{
prepareCmd: "poetry version ${nextRelease.version} && poetry build",
},
],
[
"@google/semantic-release-replace-plugin",
{
replacements: [
{
files: ["*/_version.py"],
ignore: ["tests/*"],
from: '__version__ = ".*"',
to: '__version__ = "${nextRelease.version}"',
},
],
},
],
[
"@semantic-release/git",
{
assets: ["pyproject.toml", "*/_version.py"],
message:
"🔖 camply ${nextRelease.version}\n\n${nextRelease.notes}\n[skip ci]",
},
],
[
"@semantic-release/github",
{
assets: [
{
path: "dist/*.whl",
},
{
path: "dist/*.tar.gz",
},
],
},
],
],
};
27 changes: 0 additions & 27 deletions .releaserc.yaml

This file was deleted.

0 comments on commit aa40930

Please sign in to comment.