Skip to content

Commit bcc16df

Browse files
ci: fix release workflow
Signed-off-by: Mathew Wicks <[email protected]>
1 parent 1356dbd commit bcc16df

File tree

2 files changed

+67
-48
lines changed

2 files changed

+67
-48
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,39 @@ jobs:
3030
sha256sum "$file" > "$file.sha256"
3131
done
3232
33-
- name: Create GitHub Release
34-
id: create_release
35-
uses: actions/create-release@v1
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Create GitHub Release and Upload Release Assets
34+
uses: actions/github-script@v6
3835
with:
39-
tag_name: ${{ github.ref }}
40-
release_name: Release ${{ github.ref }}
41-
draft: true
42-
prerelease: ${{ contains(github.ref, "-') }}
36+
script: |
37+
const fs = require('fs');
38+
const path = require('path');
39+
40+
const { repo: { owner, repo }, ref: tag_ref } = context;
41+
const tag_name = tag_ref.replace('refs/tags/', '');
42+
43+
// Create a draft release
44+
const response = await github.rest.repos.createRelease({
45+
owner: owner,
46+
repo: repo,
47+
tag_name: tag_name,
48+
name: `deployKF CLI ${tag_name}`,
49+
draft: true,
50+
prerelease: tag_name.includes('-'),
51+
});
52+
const { id: release_id } = response.data;
4353
44-
- name: Upload binaries and checksums
45-
run: |
46-
for file in ./bin/deploykf-*; do
47-
asset_name="$(basename $file)"
48-
asset_path="./bin/$asset_name"
49-
asset_checksum_path="./bin/$asset_name.sha256"
50-
51-
echo "Uploading $asset_name"
52-
curl \
53-
--progress-bar \
54-
--location \
55-
--request POST \
56-
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
57-
--header 'Content-Type: application/octet-stream' \
58-
--upload-file "$asset_path" \
59-
--url "${{ steps.create_release.outputs.upload_url }}?name=$asset_name"
60-
61-
echo "Uploading $asset_name.sha256"
62-
curl \
63-
--progress-bar \
64-
--location \
65-
--request POST \
66-
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
67-
--header 'Content-Type: text/plain' \
68-
--upload-file "$asset_checksum_path" \
69-
--url "${{ steps.create_release.outputs.upload_url }}?name=$asset_name.sha256"
70-
done
54+
// Upload each binary and checksum file
55+
const globber = await glob.create('./bin/deploykf-*');
56+
for await (const file of globber.globGenerator()) {
57+
const asset_name = path.basename(file);
58+
const asset_path = `./bin/${asset_name}`;
59+
60+
core.info(`Uploading ${asset_name}`);
61+
await github.rest.repos.uploadReleaseAsset({
62+
owner: owner,
63+
repo: repo,
64+
release_id: release_id,
65+
name: asset_name,
66+
data: fs.readFileSync(asset_path),
67+
});
68+
}

README.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,49 @@
1-
# deployKF - cli
1+
# deployKF - Command Line Interface (CLI)
22

3-
The CLI for [deployKF](https://github.com/deployKF/deployKF).
3+
[![Check Commit](https://github.com/deployKF/cli/actions/workflows/check-commit.yml/badge.svg)](https://github.com/deployKF/cli/actions/workflows/check-commit.yml)
4+
5+
This repo contains the command line interface (CLI) for [deployKF](https://github.com/deployKF/deployKF).
6+
7+
## Install
8+
9+
You can install the `deploykf` CLI by downloading the appropriate binary for your OS from the [releases page](https://github.com/deployKF/cli/releases).
10+
- You may wish to rename the binary to `deploykf` (or `deploykf.exe` on Windows).
11+
- On Unix-like systems, you may need to make the binary executable by running `chmod +x deploykf`.
412

513
## Usage
614

715
The simplest usage of the `deploykf` CLI is to run the following command:
816

917
```bash
1018
deploykf \
11-
--source-version=v0.1.0 \
12-
--values "./custom-values.yaml" \
13-
--output-dir "./GENERATOR_OUTPUT"
19+
--source-version v0.1.0 \
20+
--values ./custom-values.yaml \
21+
--output-dir ./GENERATOR_OUTPUT
1422
```
1523

16-
Which will generate deployKF manifests in the `./GENERATOR_OUTPUT` directory based on the `v0.1.0` source version and your `./values.yaml` file.
17-
18-
The `--source-version` flag must be a tag associated with a [deployKF release](https://github.com/deployKF/deployKF/releases).
24+
This command will generate deployKF manifests in the `./GENERATOR_OUTPUT` directory using the `v0.1.0` source version and the values specified in your `./custom-values.yaml` file.
25+
Note that the `--source-version` flag must correspond to a tag from a [deployKF release](https://github.com/deployKF/deployKF/releases).
1926

2027
## Development
2128

22-
Running `make build` will build the binary for your local platform and output it to `./bin/deploykf`.
29+
Here are some helpful commands when developing the CLI:
30+
31+
- `make build`: Builds the binary for your local platform and outputs it to `./bin/deploykf`.
32+
- `make install`: Installs the binary to `/usr/local/bin`.
33+
- `make lint`: Runs `golangci-lint` against the codebase to check for errors.
34+
- `make lint-fix`: Attempts to automatically fix any linting errors found.
2335

24-
Running `make install` will install the binary to `/usr/local/bin`.
36+
## Releasing
2537

26-
Running `make lint` will run `golangci-lint` against the codebase.
38+
To release a new version of the CLI, follow these steps:
2739

28-
Running `make lint-fix` will attempt to automatically fix linting errors.
40+
1. For a new minor or major release, create a `release-*` branch first.
41+
- For example, for the `v0.2.0` release, create a new branch called `release-0.2`.
42+
- This allows for the continued release of bug fixes to older CLI versions.
43+
2. Create a new tag on the appropriate release branch for the version you are releasing.
44+
- For instance, you might create `v0.1.1` or `v0.1.1-alpha.1` on the `release-0.1` branch.
45+
- Remember to create tags only on the `release-*` branches, not on the `main` branch.
46+
3. When a new semver tag is created, a workflow will automatically create a GitHub draft release.
47+
- The release will include binaries and corresponding SHA256 checksums for all supported platforms.
48+
- Don't forget to add the changelog to release notes.
49+
4. Manually publish the draft release.

0 commit comments

Comments
 (0)