Skip to content

Create release with beb package #4

Create release with beb package

Create release with beb package #4

name: Create release with beb package
on:
workflow_dispatch:
# pull_request:
env:
TERM: dumb
CARGO_TERM_COLOR: always
jobs:
build_and_test:
name: Creating new release with beb pacage
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Static analysis | Markdown lint tool
uses: docker://avtodev/markdown-lint:v1
with:
config: '.github/markdownlint/markdownlint.yaml'
args: "**/*.md"
- name: Static analysis | cargo check
run: |
cargo check
- name: Static analysis | cargo clippy
run: |
cargo clippy
- name: Static analysis | cargo fmt
run: |
echo -e "\033[0;31m Escaped for now because of to much of errors, will be turned on later \033[0m"
# cargo fmt --check
- name: Unit tests
run: cargo test -- --show-output
- name: Integration tests
run: |
echo -e "\033[0;31m Not implemented yet \033[0m"
# src/tests/integration/run_tests.sh
- name: Update version number in the Cargo.toml
run: |
old_version_var=$(cat ./Cargo.toml | sed -rn 's/^version[\t ]*=[\t ]*\"([0-9]+\.[0-9]+\.[0-9]+)\"\s*$/\1/gp')
echo "old version: $old_version_var"
old_build_var=$(cat ./Cargo.toml | sed -rn 's/^version[\t ]*=[\t ]*\"[0-9]+\.[0-9]+\.([0-9]+)\"\s*$/\1/gp')
echo "old build number: $old_build_var"
new_build_var=$((old_build_var+1))
echo "new build number: $new_build_var"
sed -i -r "s/^(version[\t ]*=[\t ]*\"[0-9]+\.[0-9]+\.)[0-9]+\"\s*$/\1${new_build_var}\"/g" ./Cargo.toml
new_version_var=$(cat ./Cargo.toml | sed -rn 's/^version[\t ]*=[\t ]*\"([0-9]+\.[0-9]+\.[0-9]+)\"\s*$/\1/gp')
echo "new version: $new_version_var"
echo "NEW_VERSION=$new_version_var" >> $GITHUB_ENV
echo "new version: ${{ env.NEW_VERSION }}"
- name: Build release
run: cargo build --release
- name: Build deb package
run: ./.github/workflows/packaging/deb/build.sh ${{ env.NEW_VERSION }}
- name: Commit new version
run: |
# echo ${{secrets.RELEASES_TOKEN}} | sed 's/./& /g' # trick for display hidden github env.VARIABLE
echo "on repositiry: ${{ github.repository }}"
git config --global user.name 'anton.lobanov'
git config --global user.email 'lobanov.anton@gmail.com'
git remote set-url origin https://a-givertzman:${{ secrets.RELEASES_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Automated version update to: ${{ env.NEW_VERSION }}"
- name: Push to protected branch "master"
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASES_TOKEN }}
branch: master
unprotect_reviews: true
- name: Zip artifact for deployment
run: zip ./target/release/release.zip -r ./target/release/* ./config.yaml ./extensions/*
- name: Publish release
uses: ncipollo/release-action@v1
with:
artifacts: "./target/release/release.zip,./target/cma-server_${{ env.NEW_VERSION }}_amd64.deb"
tag: internal_v${{ env.NEW_VERSION }}
token: ${{ secrets.RELEASES_TOKEN }}