mirror of
https://github.com/kbwo/testing-language-server.git
synced 2025-12-23 09:47:07 +00:00
ci: update release procedure
This commit is contained in:
parent
4e9f1b5c35
commit
7b59f5ae74
2 changed files with 111 additions and 51 deletions
71
.github/workflows/release-adapter.yml
vendored
71
.github/workflows/release-adapter.yml
vendored
|
|
@ -1,31 +1,60 @@
|
|||
name: Release
|
||||
name: Release Adapter
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'adapter-v*.*.*'
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- crates/adapter/Cargo.toml
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
check-version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version_changed: ${{ steps.check_version.outputs.version_changed }}
|
||||
new_version: ${{ steps.check_version.outputs.new_version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: Check if version changed
|
||||
id: check_version
|
||||
run: |
|
||||
PACKAGE_NAME=$(grep '^name' crates/adapter/Cargo.toml | sed 's/name = "\(.*\)"/\1/')
|
||||
RELEASED_VERSION=$(cargo search $PACKAGE_NAME --limit 1 | grep -oP '(?<=").*(?=")')
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to fetch released version"
|
||||
exit 1
|
||||
fi
|
||||
NEW_VERSION=$(grep '^version' crates/adapter/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
|
||||
|
||||
if [ "$RELEASED_VERSION" != "$NEW_VERSION" ]; then
|
||||
echo "Version changed from $RELEASED_VERSION to $NEW_VERSION"
|
||||
echo "version_changed=true" >> $GITHUB_OUTPUT
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "No version change"
|
||||
fi
|
||||
|
||||
publish:
|
||||
needs: check-version
|
||||
if: needs.check-version.outputs.version_changed == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: crates/adapter
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Build project
|
||||
run: cargo build --release
|
||||
|
||||
- name: Publish to crates.io
|
||||
env:
|
||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
run: cargo publish --token $CARGO_REGISTRY_TOKEN
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
- name: Publish to crates.io
|
||||
env:
|
||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
run: cargo publish --token $CARGO_REGISTRY_TOKEN
|
||||
|
|
|
|||
91
.github/workflows/release.yml
vendored
91
.github/workflows/release.yml
vendored
|
|
@ -1,39 +1,70 @@
|
|||
name: Release
|
||||
name: Auto Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- Cargo.toml
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
check-version:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
version_changed: ${{ steps.check_version.outputs.version_changed }}
|
||||
new_version: ${{ steps.check_version.outputs.new_version }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: Check if version changed
|
||||
id: check_version
|
||||
run: |
|
||||
PACKAGE_NAME=$(grep '^name' Cargo.toml | sed 's/name = "\(.*\)"/\1/')
|
||||
RELEASED_VERSION=$(cargo search $PACKAGE_NAME --limit 1 | grep -oP '(?<=").*(?=")')
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to fetch released version"
|
||||
exit 1
|
||||
fi
|
||||
NEW_VERSION=$(grep '^version' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
|
||||
|
||||
if [ "$RELEASED_VERSION" != "$NEW_VERSION" ]; then
|
||||
echo "Version changed from $RELEASED_VERSION to $NEW_VERSION"
|
||||
echo "version_changed=true" >> $GITHUB_OUTPUT
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "No version change"
|
||||
fi
|
||||
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
create-release:
|
||||
needs: check-version
|
||||
if: needs.check-version.outputs.version_changed == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Create Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh release create v${{ needs.check-version.outputs.new_version }} \
|
||||
--title "Release ${{ needs.check-version.outputs.new_version }}" \
|
||||
--generate-notes
|
||||
|
||||
- name: Build project
|
||||
run: cargo build --release
|
||||
|
||||
# - name: Archive the build artifacts
|
||||
# run: tar -czvf build.tar.gz -C target/release .
|
||||
#
|
||||
# - name: Create Release
|
||||
# id: create_release
|
||||
# uses: softprops/action-gh-release@v1
|
||||
# with:
|
||||
# tag_name: ${{ github.ref }}
|
||||
# files: build.tar.gz
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Publish to crates.io
|
||||
env:
|
||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
run: cargo publish --token $CARGO_REGISTRY_TOKEN
|
||||
publish:
|
||||
needs: [check-version, create-release]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
- name: Publish to crates.io
|
||||
env:
|
||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
run: cargo publish --token $CARGO_REGISTRY_TOKEN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue