Skip to content

Commit

Permalink
feat(ci): add semantic-release goal
Browse files Browse the repository at this point in the history
Adds goal `semantic-release` that installs dependencies, creates
config and workflows.

This also adds semantic-release to this project.
  • Loading branch information
Walheimat committed Jan 28, 2024
1 parent bd78359 commit 3848217
Show file tree
Hide file tree
Showing 10 changed files with 6,838 additions and 850 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release
on: workflow_dispatch

jobs:
test:
uses: ./.github/workflows/verify.yml
release:
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
submodules: true
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install dependencies
run: npm ci

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
run: npx semantic-release
11 changes: 7 additions & 4 deletions .github/workflows/verify.yaml → .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
branches:
- trunk
paths-ignore:
- '.gitignore'
- 'CHANGELOG.md'
- 'README.org'
- .gitignore
- CHANGELOG.md
- README.org
workflow_call:

jobs:
test:
Expand All @@ -27,8 +28,10 @@ jobs:

- name: Check out the repository
uses: actions/checkout@v3
with:
submodules: true

- name: Install dependencies with Cask
- name: Tangle and install dependencies with Cask
run: make

- name: Run tests
Expand Down
45 changes: 45 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"branches": [
"trunk"
],
"repositoryUrl": "git@github.com:Walheimat/dinghy.git",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"type": "feat",
"release": "patch"
}
]
},
],
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec",
{
"prepareCmd": "make update-next-version NEXT_PACKAGE_VERSION=${nextRelease.version}"
}
],
[
"@semantic-release/changelog",
{
"changelogTitle": "# Changelog"
}
],
[
"@semantic-release/git",
{
"assets": [
"src/dinghy-rope.el",
"src/dinghy-pacify.el",
"CHANGELOG.md",
"Makefile",
"emacs-package.mk"
]
}
]
]
}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DINGHY_DIR="."
UPDATE_VERSION_FILES=src/dinghy-pacify.el src/dinghy-rope.el emacs-package.mk
UPDATE_VERSION_FILES=src/dinghy-pacify.el src/dinghy-rope.el emacs-package.mk Makefile
CURRENT_PACKAGE_VERSION=0.4.0
PACKAGE_NAME=dinghy

include emacs-package.mk
19 changes: 19 additions & 0 deletions emacs-package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,24 @@ clean-commits:
rm -f commitlint.config.js package.json package-lock.json
git config --unset core.hooksPath

## Semantic-Release

.PHONY: semantic-release
semantic-release:
ifdef PACKAGE_NAME
$(info Copying semantic-release config, be sure to adjust)
sed -e 's/%PACKAGE%/$(PACKAGE_NAME)/' $(TEMPLATES_DIR)/semantic-release/.releaserc > .releaserc
else
$(info You need to set PACKAGE_NAME to copy config)
endif
$(info Installing dependencies)
npm install --save-dev semantic-release \
@semantic-release/changelog \
@semantic-release/git \
@semantic-release/exec \
conventional-changelog-conventionalcommits
cp -f $(TEMPLATES_DIR)/semantic-release/release.yml .github/workflows/release.yml
cp -f $(TEMPLATES_DIR)/semantic-release/verify.yml .github/workflows/verify.yml

# Run `make V=1 {cmd}` to print commands
$(V).SILENT:
Loading

0 comments on commit 3848217

Please sign in to comment.