publish #80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: automatic_test_build_publish | |
on: | |
- repository_dispatch | |
- workflow_dispatch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Checkout repository with submodules | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Fetch release version | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
echo TAG_NAME=$(gh release view --repo /~https://github.com/ArunaStorage/ArunaAPI --json tagName | jq .tagName -r) >> $GITHUB_ENV | |
echo RELEASE_NAME=$(gh release view --repo /~https://github.com/ArunaStorage/ArunaAPI --json name | jq .name -r) >> $GITHUB_ENV | |
echo RELEASE_BODY=$(gh release view --repo /~https://github.com/ArunaStorage/ArunaAPI --json body | jq .body -r) >> $GITHUB_ENV | |
- name: Update tag | |
run: | | |
VERSIONLESS=$(echo $TAG_NAME | sed -e 's/^v//') | |
sed -i -e "s/^version = .*/version = \"$VERSIONLESS\"/" Cargo.toml | |
- name: Pull rust stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Git Submodule Update | |
run: | | |
git pull --recurse-submodules | |
git submodule update --init --recursive | |
git submodule update --remote --recursive | |
- name: Compile protofiles with rust | |
run: cargo build --release | |
- name: Commit files | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add -A | |
git diff-index --quiet HEAD || git commit -m "Update to version $TAG_NAME" -a | |
git tag -a $TAG_NAME -m "Published new version: $TAG_NAME, see API for detailed changelog." | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tags: true | |
force: true | |
- name: Cargo publish | |
run: cargo publish --token ${CRATES_TOKEN} | |
env: | |
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} | |
- name: Try delete (old) release if exists | |
run: gh release delete $TAG_NAME | |
continue-on-error: true | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
run: gh release create $TAG_NAME --title "$RELEASE_NAME" --notes "$RELEASE_BODY" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |