Skip to content

Commit 59d1de0

Browse files
committed
Add possibility to attach files in release, fix #2
1 parent 8c3afd3 commit 59d1de0

File tree

3 files changed

+87
-7
lines changed

3 files changed

+87
-7
lines changed

.github/workflows/create-release.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: "Create release"
22

33
on:
44
workflow_call:
5+
inputs:
6+
artifact_name:
7+
description: 'The name of the artifact to download. Default to no artifact downloaded.'
8+
required: false
9+
type: string
10+
files:
11+
description: 'Newline-delimited globs of paths to assets to upload for release, must be found in the downloaded artifact.'
12+
required: false
13+
type: string
514

615
jobs:
716
create_release:
@@ -26,15 +35,20 @@ jobs:
2635
with:
2736
version: ${{ steps.extract-version.outputs.version }}
2837

38+
- name: Download artifacts for release
39+
if: ${{ inputs.artifact_name }}
40+
uses: actions/download-artifact@v2
41+
with:
42+
name: ${{ inputs.artifact_name }}
43+
2944
- name: Create GitHub release
30-
uses: actions/create-release@v1
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
uses: softprops/[email protected]
3346
with:
47+
name: ${{ steps.extract-version.outputs.version }}
3448
tag_name: ${{ format('v{0}', steps.extract-version.outputs.version) }}
35-
release_name: ${{ steps.extract-version.outputs.version }}
49+
fail_on_unmatched_files: ${{ inputs.artifact_name }}
3650
draft: false
3751
prerelease: false
3852
body: ${{ steps.changelog.outputs.description }}
39-
commitish: ${{ github.event.pull_request.merge_commit_sha }}
40-
53+
target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
54+
files: ${{ inputs.files }}

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add workflow call inputs on `create-release.yml` workflow to pass an artifact containing files to attached to the release
13+
14+
### Changed
15+
16+
- Improved documentation on how to chain and trigger workflows
17+
1018
## [1.0.1] - 2021-10-29
1119

1220
### Fixed

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,54 @@ jobs:
5858
uses: farcaster-project/workflows/.github/workflows/[email protected]
5959
```
6060

61+
If you want to attached files to the release you can declare a `create_release` job with:
62+
63+
```yaml
64+
jobs:
65+
produce_binaries:
66+
name: Compile released binaries
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v2
70+
71+
- name: Compile released binaries
72+
run: ...
73+
74+
- name: Archive release folder
75+
uses: actions/upload-artifact@v2
76+
with:
77+
name: release-folder
78+
path: target/release
79+
retention-days: 7
80+
81+
create_release:
82+
name: Create from merged release branch
83+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
84+
uses: farcaster-project/workflows/.github/workflows/[email protected]
85+
needs: produce_binaries
86+
with:
87+
artifact_name: release-folder
88+
files: |
89+
target/release/bin1
90+
target/release/bin2
91+
```
92+
93+
You can add another job after `create_release`, e.g. `releast_to_crates`, triggered only when the first is successfully completed i.e. when the release is published with:
94+
95+
```yaml
96+
releast_to_crates:
97+
name: Release to crates.io
98+
uses: farcaster-project/workflows/.github/workflows/[email protected]
99+
needs: create_release
100+
secrets:
101+
cratesio_token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
102+
```
103+
104+
Or use the method below with `workflow_run: workflows: ["Name of the worflow"]` to keep separated files.
105+
61106
### Release to crates.io
62107

63-
`release-to-crates-io.yml` publish the crate to crates.io under the authentified user by **cratesio_token**. Example of usage:
108+
`release-to-crates-io.yml` publish the crate to crates.io under the authentified user by **cratesio_token**. Example of stand-alone usage (see above for chained usage after `create_release`):
64109

65110
```yaml
66111
name: Release to crates.io
@@ -77,6 +122,19 @@ jobs:
77122
cratesio_token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
78123
```
79124

125+
If you want to trigger this workflow after another you can add:
126+
127+
```yaml
128+
# Trigger when the "Create release" workflow succeeded
129+
on:
130+
workflow_run:
131+
workflows: ["Create release"]
132+
types:
133+
- completed
134+
```
135+
136+
Where `"Create release"` is the name of the workflow that will trigger the `"Release to crates.io"` workflow when completed.
137+
80138
## Changelog
81139

82140
See [CHANGELOG.md](CHANGELOG.md) for detailed version logs.

0 commit comments

Comments
 (0)