Skip to content

Commit fb4f8a3

Browse files
authored
Add build and publish dry run when drafting new release (#14)
* feat: add build and publish dry run when drafting new release * doc: update changelog * doc: add new inputs default
1 parent ef2d055 commit fb4f8a3

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/draft-new-release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ on:
77
description: 'The new version in major.minor.patch format.'
88
required: true
99
type: string
10+
build:
11+
description: 'Build the projet with cargo, useful when Cargo.lock is commited and needs to be updated.'
12+
required: false
13+
default: false
14+
type: boolean
15+
check_publish:
16+
description: 'Dry run cargo publish before pushing changes, useful to not allow unpublishable releases.'
17+
required: false
18+
default: false
19+
type: boolean
1020

1121
jobs:
1222
draft-new-release:
@@ -30,11 +40,25 @@ jobs:
3040
version: ${{ github.event.inputs.version }}
3141
manifest: Cargo.toml
3242

43+
- name: Install latest stable
44+
uses: actions-rs/toolchain@v1
45+
with:
46+
default: true
47+
override: true
48+
49+
- name: Cargo build update lockfile
50+
if: ${{ inputs.build }}
51+
run: cargo build
52+
3353
- name: Format CHANGELOG
3454
run: |
3555
curl -fsSL https://dprint.dev/install.sh | sh
3656
/home/runner/.dprint/bin/dprint fmt CHANGELOG.md
3757
58+
- name: Publish dry run
59+
if: ${{ inputs.check_publish }}
60+
run: cargo publish --dry-run --allow-dirty
61+
3862
- name: Add, Commit & Push
3963
id: make-commit
4064
uses: EndBug/add-and-commit@v9.0.0

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- New input `build` for `draft-new-release.yml` to build the crate before add & commit the files, allows lockfile update
13+
- New input `check_publish` for `draft-new-release.yml` to dry run the cargo publish before add & commit the files, allows to not open a PR on unpublishable state.
14+
1015
## [1.0.2] - 2021-11-01
1116

1217
### Added

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ You can find an example of usage for the following shared workflows.
1111

1212
### Draft new release
1313

14-
`draft-new-release.yml` prepare the creation of a new release by creating a new branch `release/{version}` and opening a pull request targeting `main`. **The changelog is updated with the `{version}` parameter and today's date and the `Cargo.toml` version is updated with the new `{version}`**. Version should follow semantic versioning.
14+
`draft-new-release.yml` prepare the creation of a new release by creating a new branch `release/{version}` and opening a pull request targeting `main`.
15+
16+
**The changelog is updated to `{version}` and today's date. `Cargo.toml` version is updated to `{version}` and `Cargo.toml` is updated if input `build` (default false) is set to true. Set input `check_publish` (default false) to dry run publish**.
17+
18+
> Version should follow semantic versioning.
1519
1620
The commit will be associated with GitHub Actions bot.
1721

@@ -33,6 +37,8 @@ jobs:
3337
uses: farcaster-project/workflows/.github/workflows/draft-new-release.yml@v1.0.2
3438
with:
3539
version: ${{ github.event.inputs.version }}
40+
build: false
41+
check_publish: true
3642
```
3743
3844
### Create release

0 commit comments

Comments
 (0)