Skip to content

Commit dfb5aba

Browse files
authored
ci: automate crate publishing (#337)
1 parent eaa43c3 commit dfb5aba

File tree

7 files changed

+189
-19
lines changed

7 files changed

+189
-19
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release crates
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches:
11+
- master
12+
13+
jobs:
14+
# Create a PR with the new versions and changelog, preparing the next release.
15+
open-pr:
16+
name: Open release PR
17+
runs-on: ubuntu-latest
18+
environment: cratesio-publish
19+
20+
concurrency:
21+
group: release-plz-${{ github.ref }}
22+
cancel-in-progress: false
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 512
29+
30+
- name: Run release-plz
31+
id: release-plz
32+
uses: Devolutions/actions-public/release-plz@v1
33+
with:
34+
command: release-pr
35+
git-name: Devolutions Bot
36+
git-email: bot@devolutions.net
37+
github-token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}
38+
39+
- name: Update ffi/wasm/Cargo.lock
40+
shell: pwsh
41+
if: ${{ steps.release-plz.outputs.did-open-pr == 'true' }}
42+
run: |
43+
$prRaw = '${{ steps.release-plz.outputs.pr }}'
44+
Write-Host "prRaw: $prRaw"
45+
46+
$pr = $prRaw | ConvertFrom-Json
47+
Write-Host "pr: $pr"
48+
49+
Write-Host "Fetch branch $($pr.head_branch)"
50+
git fetch origin "$($pr.head_branch)"
51+
52+
Write-Host "Switch to branch $($pr.head_branch)"
53+
git checkout "$($pr.head_branch)"
54+
55+
Write-Host "Update ./ffi/wasm/Cargo.lock"
56+
cargo update --manifest-path ./ffi/wasm/Cargo.toml
57+
58+
Write-Host "Update last commit"
59+
git add ./ffi/wasm/Cargo.lock
60+
git commit --amend --no-edit
61+
62+
Write-Host "Update the release pull request"
63+
git push --force
64+
65+
# Release unpublished packages.
66+
release:
67+
name: Release crates
68+
runs-on: ubuntu-latest
69+
environment: cratesio-publish
70+
71+
steps:
72+
- name: Checkout repository
73+
uses: actions/checkout@v4
74+
with:
75+
fetch-depth: 512
76+
77+
- name: Run release-plz
78+
uses: Devolutions/actions-public/release-plz@v1
79+
with:
80+
command: release
81+
registry-token: ${{ secrets.CRATES_IO_TOKEN }}

cliff.toml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Configuration file for git-cliff
2+
3+
[changelog]
4+
trim = false
5+
6+
header = """
7+
# Changelog
8+
9+
All notable changes to this project will be documented in this file.
10+
11+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
12+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
13+
14+
"""
15+
16+
# https://tera.netlify.app/docs/#introduction
17+
body = """
18+
{% if version -%}
19+
## [[{{ version | trim_start_matches(pat="v") }}]{%- if release_link -%}({{ release_link }}){% endif %}] - {{ timestamp | date(format="%Y-%m-%d") }}
20+
{%- else -%}
21+
## [Unreleased]
22+
{%- endif %}
23+
24+
{% for group, commits in commits | group_by(attribute="group") -%}
25+
26+
### {{ group | upper_first }}
27+
28+
{%- for commit in commits %}
29+
30+
{%- set message = commit.message | upper_first %}
31+
32+
{%- if commit.breaking %}
33+
{%- set breaking = "[**breaking**] " %}
34+
{%- else %}
35+
{%- set breaking = "" %}
36+
{%- endif %}
37+
38+
{%- set short_sha = commit.id | truncate(length=10, end="") %}
39+
{%- set commit_url = "https://github.com/Devolutions/picky-rs/commit/" ~ commit.id %}
40+
{%- set commit_link = "[" ~ short_sha ~ "](" ~ commit_url ~ ")" %}
41+
42+
- {{ breaking }}{{ message }} ({{ commit_link }}) \
43+
{% if commit.body %}\n\n {{ commit.body | replace(from="\n", to="\n ") }}{% endif %}
44+
{%- endfor %}
45+
46+
{% endfor -%}
47+
"""
48+
49+
footer = ""
50+
51+
[git]
52+
conventional_commits = true
53+
filter_unconventional = false
54+
filter_commits = false
55+
date_order = false
56+
protect_breaking_commits = true
57+
sort_commits = "oldest"
58+
59+
commit_preprocessors = [
60+
# Replace issue number with the link
61+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/Devolutions/picky-rs/issues/${2}))"},
62+
# Replace commit sha1 with the link
63+
{ pattern = '([a-f0-9]{10})([a-f0-9]{30})', replace = "[${0}](https://github.com/Devolutions/picky-rs/commit/${1}${2})" }
64+
]
65+
66+
# regex for parsing and grouping commits
67+
# <!-- <NUMBER> --> is a trick to control the section order: https://github.com/orhun/git-cliff/issues/9#issuecomment-914521594
68+
commit_parsers = [
69+
{ message = "^chore", skip = true },
70+
{ message = "^style", skip = true },
71+
{ message = "^refactor", skip = true },
72+
{ message = "^test", skip = true },
73+
{ message = "^ci", skip = true },
74+
{ message = "^chore\\(release\\): prepare for", skip = true },
75+
{ footer = "^[Cc]hangelog: ?ignore", skip = true },
76+
77+
{ message = "(?i)security", group = "<!-- 0 -->Security" },
78+
{ body = "(?i)security", group = "<!-- 0 -->Security" },
79+
{ footer = "^[Ss]ecurity: ?yes", group = "<!-- 0 -->Security" },
80+
81+
{ message = "^feat", group = "<!-- 1 -->Features" },
82+
83+
{ message = "^revert", group = "<!-- 3 -->Revert" },
84+
{ message = "^fix", group = "<!-- 4 -->Bug Fixes" },
85+
{ message = "^perf", group = "<!-- 5 -->Performance" },
86+
{ message = "^doc", group = "<!-- 6 -->Documentation" },
87+
{ message = "^build", group = "<!-- 7 -->Build" },
88+
89+
{ message = "(?i)improve", group = "<!-- 2 -->Improvements" },
90+
{ message = "(?i)adjust", group = "<!-- 2 -->Improvements" },
91+
{ message = "(?i)change", group = "<!-- 2 -->Improvements" },
92+
93+
{ message = ".*", group = "<!-- 99 -->Please Sort" },
94+
]

picky-asn1-der/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## Unreleased
9-
108
## [0.5.1] 2024-11-26
119

1210
### Changed

picky-asn1-x509/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## Unreleased
9-
108
## [0.14.1] 2024-11-26
119

1210
### Changed

picky-asn1/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## Unreleased
9-
108
## [0.10.0] 2024-11-26
119

1210
### Fixed

picky/CHANGELOG.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
<!-- next-header -->
9-
10-
## [Unreleased] – ReleaseDate
8+
## [7.0.0-rc.1 to 7.0.0-rc.11](https://github.com/Devolutions/picky-rs/compare/picky-6.4.0...picky-v7.0.0-rc.11)
119

1210
### Added
1311

@@ -82,6 +80,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8280
- PuTTY PPK key format support
8381

8482
### Changed
83+
8584
- Bump minimal rustc version to 1.70
8685
- Updated `p256`/`p384` to latest version
8786
- (Breaking) Move Authenticode related code from `picky::x509::wincert` to `picky::x509::pkcs7::authenticode` module
@@ -97,6 +96,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9796
- "picky-test-data" is a new dev-dependency.
9897

9998
### Removed
99+
100100
- (Breaking) `ec` non-default cargo feature (EC operations now enabled by default)
101101

102102
### Fixed
@@ -119,13 +119,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
119119
- Fixed invalid padding logic of encrypted SSH keys
120120
- Fixed invalid generated SSH EC keys
121121

122-
123122
### Removed
124123

125124
- (Breaking) `Jwt::new_encrypted`
126125
- (Breaking) `Jwt::new_signed`
127126

128-
## [6.4.0] – 2021-08-10
127+
## [6.4.0](https://github.com/Devolutions/picky-rs/compare/picky-6.3.0...picky-6.4.0) – 2021-08-10
129128

130129
### Changed
131130

@@ -134,7 +133,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
134133
- Update `picky-asn1` dependency to `0.4`
135134
- More robust certification validation (see commit [f5f8cb60e41](https://github.com/Devolutions/picky-rs/commit/f5f8cb60e410ffe49aabace131f7b802e206ced0) for details)
136135

137-
## [6.3.0] – 2021-05-27
136+
## [6.3.0](https://github.com/Devolutions/picky-rs/compare/picky-6.2.0...picky-6.3.0) – 2021-05-27
138137

139138
### Added
140139

@@ -145,7 +144,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
145144

146145
- Update `aes-gcm` dependency to `0.9`
147146

148-
## [6.2.0] – 2021-03-04
147+
## [6.2.0](https://github.com/Devolutions/picky-rs/compare/picky-6.1.1...picky-6.2.0) – 2021-03-04
149148

150149
### Added
151150

@@ -251,9 +250,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
251250
### Deprecated
252251

253252
- `Cert::verify` and `Cert::verify_chain` methods in favor of the `Cert::verifier` method.
254-
255-
<!-- next-url -->
256-
[Unreleased]: https://github.com/Devolutions/picky-rs/compare/picky-6.4.0...HEAD
257-
[6.4.0]: https://github.com/Devolutions/picky-rs/compare/picky-6.3.0...picky-6.4.0
258-
[6.3.0]: https://github.com/Devolutions/picky-rs/compare/picky-6.2.0...picky-6.3.0
259-
[6.2.0]: https://github.com/Devolutions/picky-rs/compare/picky-6.1.1...picky-6.2.0

release-plz.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
dependencies_update = true
3+
git_release_enable = false
4+
semver_check = true
5+
pr_branch_prefix = "release-plz/"
6+
pr_name = "chore(release): prepare for publishing"
7+
changelog_config = "cliff.toml"
8+
release_commits = "^(feat|docs|fix|build|perf)"

0 commit comments

Comments
 (0)