Skip to content

Commit 280a3bd

Browse files
authored
Merge pull request #57 from snyk/feat/tag-and-release
ci: tag and release
2 parents c7723c0 + 8e9c05d commit 280a3bd

File tree

6 files changed

+438
-28
lines changed

6 files changed

+438
-28
lines changed

.circleci/config.yml

Lines changed: 98 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,43 +67,114 @@ jobs:
6767
mode: auto
6868
iac-scan: disabled
6969

70+
determine-version:
71+
<<: *go_image
72+
steps:
73+
- checkout
74+
- run:
75+
name: Determine version bump and save to workspace
76+
command: |
77+
chmod +x ./script/version-bump.sh
78+
./script/version-bump.sh
79+
80+
# Source the environment to make variables available
81+
source $BASH_ENV
82+
83+
# Save to workspace
84+
mkdir -p /tmp/workspace
85+
echo "$BUMP_TYPE" > /tmp/workspace/bump_type
86+
echo "$NEW_VERSION" > /tmp/workspace/new_version
87+
echo "$NEW_TAG" > /tmp/workspace/new_tag
88+
echo "$PREVIOUS_TAG" > /tmp/workspace/previous_tag
89+
- persist_to_workspace:
90+
root: /tmp/workspace
91+
paths:
92+
- bump_type
93+
- new_version
94+
- new_tag
95+
- previous_tag
96+
97+
tag-release:
98+
<<: *go_image
99+
steps:
100+
- checkout
101+
- attach_workspace:
102+
at: /tmp/workspace
103+
- run:
104+
name: Configure git
105+
command: |
106+
git config user.email "[email protected]"
107+
git config user.name "Snyk CI"
108+
- run:
109+
name: Create and push tag
110+
command: |
111+
BUMP_TYPE=$(cat /tmp/workspace/bump_type)
112+
NEW_TAG=$(cat /tmp/workspace/new_tag)
113+
114+
if [ "$BUMP_TYPE" = "none" ]; then
115+
echo "Chore commit detected - skipping tag creation"
116+
circleci-agent step halt
117+
fi
118+
119+
echo "Creating tag: $NEW_TAG"
120+
git tag -a "$NEW_TAG" -m "Release $NEW_TAG"
121+
122+
# Push using HTTPS with GitHub token (no fingerprint needed)
123+
git push https://${GH_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} "$NEW_TAG"
124+
125+
# Filters for branches
126+
filters_pr_only: &filters_pr_only
127+
filters:
128+
branches:
129+
ignore:
130+
- main
131+
132+
filters_main_only: &filters_main_only
133+
filters:
134+
branches:
135+
only:
136+
- main
137+
70138
workflows:
71139
version: 2
72-
CI:
140+
test-and-tag:
73141
jobs:
142+
# PR-only jobs - all testing
143+
- lint:
144+
<<: *filters_pr_only
145+
146+
- unit_test:
147+
<<: *filters_pr_only
148+
74149
- prodsec/secrets-scan:
75150
name: Scan repository for secrets
76151
context:
77152
- snyk-bot-slack
78153
channel: snyk-vuln-alerts-unify
79-
filters:
80-
branches:
81-
ignore:
82-
- main
83-
- security-scans:
84-
name: Security Scans
85-
context:
86-
- analysis_unify
87-
- lint:
88-
name: Lint
89-
filters:
90-
branches:
91-
ignore:
92-
- main
93-
- unit_test:
94-
name: Unit tests
95-
filters:
96-
branches:
97-
ignore:
98-
- main
154+
<<: *filters_pr_only
155+
99156
- python_integration_test:
100-
name: Python << matrix.python_version >> integration tests
101157
requires:
102-
- Unit tests
158+
- unit_test
103159
matrix:
104160
parameters:
105161
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
106-
filters:
107-
branches:
108-
ignore:
109-
- main
162+
<<: *filters_pr_only
163+
164+
# Main branch only - security scans and tagging (no test re-runs)
165+
- security-scans:
166+
context:
167+
- analysis_unify
168+
<<: *filters_main_only
169+
170+
- determine-version:
171+
requires:
172+
- security-scans
173+
<<: *filters_main_only
174+
175+
- tag-release:
176+
context:
177+
- os-ecosystems
178+
requires:
179+
- determine-version
180+
<<: *filters_main_only
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: PR Title Check
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
- reopened
10+
11+
jobs:
12+
validate-pr-title:
13+
name: Validate PR Title
14+
runs-on: ubuntu-latest
15+
permissions:
16+
pull-requests: write
17+
steps:
18+
- name: Conventional Commit In Pull Requests
19+
uses: ytanikin/[email protected]
20+
with:
21+
task_types: '["feat","fix","docs","style","refactor","perf","test","build","ci","chore","revert"]'

CONTRIBUTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,59 @@
33
This repo is intended for internal (Snyk) contributions only at this time.
44

55
Please [reach our support](SUPPORT.md) to give any feedback.
6+
7+
## Commit Message Convention
8+
9+
This project uses **Conventional Commits** for automated versioning and releases. Please follow this format when committing or creating pull requests:
10+
11+
### Format
12+
```
13+
<type>[optional scope]: <description>
14+
15+
[optional body]
16+
17+
[optional footer(s)]
18+
```
19+
20+
### Types and Their Effect on Versioning
21+
22+
- **`fix:`** - Bug fixes (bumps **PATCH** version: 1.0.0 → 1.0.1)
23+
- **`feat:`** - New features (bumps **MINOR** version: 1.0.0 → 1.1.0)
24+
- **`type!:`** - Breaking changes (bumps **MAJOR** version: 1.0.0 → 2.0.0)
25+
- **`chore:`**, **`docs:`**, **`style:`**, **`refactor:`**, **`test:`**, **`ci:`** - No release created
26+
27+
### Examples
28+
29+
```bash
30+
# Patch release
31+
fix: resolve memory leak in dependency parser
32+
fix(parser): handle edge case in requirements file
33+
34+
# Minor release
35+
feat: add support for Python 3.13
36+
feat(python): add environment marker support
37+
38+
# Major release (breaking changes - use ! indicator)
39+
fix!: change API return type
40+
feat(api)!: redesign core interface
41+
refactor!: remove deprecated parser
42+
chore!: drop support for Python 3.7
43+
44+
# No release
45+
chore: update CI configuration
46+
docs: improve README documentation
47+
```
48+
49+
### Pull Request Guidelines
50+
51+
When creating a pull request:
52+
1. **Use a descriptive title** following the conventional commit format (examples above)
53+
2. **Check the GitHub Action** - A check will automatically validate your PR title format
54+
- ✅ Check passes if title is valid (e.g., `feat:`, `fix:`, `fix!:`)
55+
- ❌ Check fails if title format is invalid
56+
3. **Edit the title if needed** - If validation fails, edit your PR title before merging
57+
4. **Use "Squash and merge"** - The PR title will become the commit message
58+
5. **Ensure all tests pass** before merging
59+
6. **Releases are automatic** - When merged to `main`, CircleCI will automatically create a release
60+
61+
For more details, see the [Release Process Documentation](docs/RELEASE.md).

0 commit comments

Comments
 (0)