Skip to content

Commit

Permalink
ci: prepare for publishing to crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Jan 5, 2025
1 parent 2ea0f55 commit f7720ec
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
60 changes: 42 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ jobs:
- name: Set up Rust
run: |
rustup default nightly
- name: Install semantic-release-cargo
uses: taiki-e/install-action@v2
with:
tool: semantic-release-cargo@2

- name: Prepare semantic-release for Rust
run: semantic-release-cargo prepare ${{ needs.get-next-version.outputs.new-release-version }}
- name: Install additional targets
run: rustup target add ${{ matrix.target }}
Expand Down Expand Up @@ -134,20 +126,50 @@ jobs:
fetch-depth: 0
ref: client-server

- name: Cache Cargo
uses: actions/cache@v4
id: cargo-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: x86_64-unknown-linux-musl-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install semantic-release-cargo
uses: taiki-e/install-action@v2
with:
tool: semantic-release-cargo@2

- name: Prepare semantic-release for Rust
run: semantic-release-cargo prepare ${{ needs.get-next-version.outputs.new-release-version }}

- name: Check Server Version
run: |
CARGO_VERSION=$(grep '^version = ' Cargo.toml | cut -d'"' -f2)
SERVER_VERSION=$(cat .github/server-version.txt | tr -d '\n')
if [ "$CARGO_VERSION" != "$SERVER_VERSION" ]; then
echo "$CARGO_VERSION" > .github/server-version.txt
git checkout client-server
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .github/server-version.txt
git commit -m "chore: update server version to $CARGO_VERSION [skip ci]"
git push
git checkout client-server
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add Cargo.toml Cargo.lock
git commit -m "build: bump project version to $CARGO_VERSION [skip ci]"
changes=$(git diff --name-only $(git describe --tags --abbrev=0)..HEAD -- src/)
if [ -n "$changes" ]; then
CARGO_VERSION="${{ needs.get-next-version.outputs.new-release-version }}"
SERVER_VERSION=$(cat .github/server-version.txt | tr -d '\n')
if [ "$CARGO_VERSION" != "$SERVER_VERSION" ]; then
echo "Server version needs to be updated"
echo "$CARGO_VERSION" > .github/server-version.txt
git add .github/server-version.txt
git commit -m "chore: update server version to $CARGO_VERSION [skip ci]"
fi
fi
git push
release:
runs-on: ubuntu-latest
if: needs.get-next-version.outputs.new-release-published == 'true'
Expand All @@ -167,11 +189,13 @@ jobs:
- name: Invoke semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
npm install -g semantic-release
npm install -g @semantic-release/changelog
npm install -g @semantic-release/git
npm install -g @semantic-release/github
npm install -g @semantic-release-cargo/semantic-release-cargo
npx semantic-release --repository-url https://github.com/vyfor/cord.nvim
luarocks:
Expand Down
9 changes: 9 additions & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ module.exports = {
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
["@semantic-release-cargo/semantic-release-cargo"],
[
"@semantic-release/exec",
{
"verifyConditionsCmd": "./semantic-release-cargo verify-conditions",
"prepareCmd": "./semantic-release-cargo prepare ${nextRelease.version}",
"publishCmd": "./semantic-release-cargo publish"
}
]
]
}

0 comments on commit f7720ec

Please sign in to comment.