Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Github build action and improve releases #422

Merged
merged 10 commits into from
Nov 1, 2023
Merged
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Build binaries
# This action triggers a GitLab CI job. The job first builds the project and then runs the tests.
# If the latest merged commit contains the keyword "release:", the job will also try to create a new release on GitHub.
# The release will be created with the tag "vX.Y.Z", where X.Y.Z is the version number of the `clients/vault` package.
name: Test, Build and Release
on:
push:
branches:
spacewalk-release
- 'main'

jobs:
build:
Expand All @@ -12,6 +15,7 @@ jobs:
- name: trigger job
uses: appleboy/gitlab-ci-action@master
with:
url: "https://gitlab.com"
host: "https://gitlab.com"
token: ${{ secrets.GITLABAPI }}
debug: true
project_id: 43970950
8 changes: 8 additions & 0 deletions .maintain/create_minor_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Find all Cargo.toml files in the current directory and its subdirectories
for file in $(find . -name "Cargo.toml")
do
# Use awk to increment the minor version number of the package
awk -F'.' '/\[package\]/,/version =/ { if($0 ~ /version =/ && $0 !~ /#/) {print $1"."$2+1".0"; next} }1' $file > temp && mv temp $file
done
8 changes: 8 additions & 0 deletions .maintain/create_patch_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Find all Cargo.toml files in the current directory and its subdirectories
for file in $(find . -name "Cargo.toml")
do
# Use awk to increment the version number of the package
awk -F'.' '/\[package\]/,/version =/ { if($0 ~ /version =/ && $0 !~ /#/) {print $1"."$2"."$3+1; next} }1' $file > temp && mv temp $file
done
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,25 @@ You can install the hook by running the following commands.

```
.maintain/add-pre-commit.sh
```
```

# Releases

To automatically create a new release for Spacewalk, please follow these steps:

- Create a new release branch with the following command:
```
git checkout -b release/vX.Y.Z
```
- Update the version number of all crates in `Cargo.toml` files. To do this you should use either
the `.maintain/create_minor_release.sh` or `.maintain/create_patch_release.sh` script. The script will bump the
version number of all crates.
- Create a new release commit with the following command:
```
git commit -a -m "release: Release vX.Y.Z"
```
- Create a pull request for the release branch and merge it into the `main` branch. The title of this PR **has to
contain**
the **"release:"** prefix. This indicates that the CI should create a new release.

Once merged, the CI will create a new release and automatically publish it to GitHub.
Loading