Skip to content

Commit

Permalink
ci: automate the releases (#178)
Browse files Browse the repository at this point in the history
Fixes #77

Co-authored-by: Stefan Seemayer <stefan@seemayer.de>
  • Loading branch information
louib and sseemayer authored Oct 22, 2023
1 parent aa3a2ea commit 22215fa
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,74 @@ jobs:
with:
fail_ci_if_error: true
verbose: true

get-next-version:
name: Get the next version
runs-on: ubuntu-latest
outputs:
version : ${{ steps.semantic-version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: paulhatch/semantic-version@976ff820fcdca81ffc95e385a07b7eff05ddccc3
id: semantic-version
with:
tag_prefix: "v"
major_pattern: "/^breaking change:/"
major_regexp_flags: "ig"
minor_pattern: "/^feat:/"
minor_regexp_flags: "ig"
version_format: "${major}.${minor}.${patch}"
bump_each_commit: false
search_commit_body: true
enable_prerelease_mode: true

release:
name: Publish a new release
needs:
- get-next-version
- test
- coverage
permissions:
# This permission is required in order to push the new
# tag to the repository.
contents: write
runs-on: ubuntu-latest
env:
next-version: ${{ needs.get-next-version.outputs.version }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Print the next version
run: |
echo "The next version is ${{ env.next-version }}"
- name: Patch the Cargo version
run: |
sed -i 's/0.0.0-placeholder-version/${{ env.next-version }}/' Cargo.toml
git diff
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Publish new Cargo version
env:
# This token needs to be created with the publish-update scope.
# The other scopes are not necessary.
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish --allow-dirty
- name: Tag the next version
run: |
new_tag_name="v${{ env.next-version }}"
git tag "$new_tag_name" "${{ github.sha }}"
git push origin "$new_tag_name"
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage = "https://github.com/sseemayer/keepass-rs"
repository = "https://github.com/sseemayer/keepass-rs"
documentation = "https://docs.rs/keepass"

version = "0.6.1"
version = "0.0.0-placeholder-version"
authors = ["Stefan Seemayer <stefan@seemayer.de>"]
license = "MIT"

Expand Down

0 comments on commit 22215fa

Please sign in to comment.