Build and Release #28
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: Build and Release | |
on: | |
push: | |
branches: ["master"] | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build-win-x64: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- uses: Swatinem/rust-cache@v2 | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --all-features | |
- name: Creating scoop manifest | |
working-directory: ./release | |
run: python make_scoop_manifest.py > tmaze.json | |
- name: Get version and rename file to version specific | |
run: | | |
$tmversion = ./target/release/tmaze.exe --version | Select-String -Pattern '^tmaze ([0-9]+\.[0-9]+\.[0-9]+)$' | %{$_.Matches[0].Groups[1].Value} | |
$filepath = "./target/release/tmaze-${tmversion}-win-x86_64.exe" | |
echo "BIN_FILEPATH=$filepath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | |
echo "TM_VERSION=$tmversion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | |
mv ./target/release/tmaze.exe ${filepath} | |
- run: echo "$Env:GITHUB_CONTEXT" | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: | | |
${{env.BIN_FILEPATH}} | |
./release/tmaze.json | |
name: release | |
build-linux-x64: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v2 | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --all-features | |
- run: strip ./target/release/tmaze | |
- run: ls -l ./target/release/ | |
- run: | | |
versionregex="tmaze ([0-9]+\.[0-9]+\.[0-9]+)" | |
if [[ $(./target/release/tmaze --version) =~ $versionregex ]]; then | |
version=${BASH_REMATCH[1]} | |
filepath="./target/release/tmaze-$version-linux-x86_64" | |
echo "BIN_FILEPATH=$filepath" >> $GITHUB_ENV | |
echo "TM_VERSION=$version" >> $GITHUB_ENV | |
echo $version > ./target/release/version | |
mv ./target/release/tmaze $filepath | |
else | |
echo "FAIL" | |
fi | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: | | |
${{env.BIN_FILEPATH}} | |
./target/release/version | |
name: release | |
draft-release: | |
needs: ["build-win-x64", "build-linux-x64"] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
path: release-files/ | |
name: release | |
- run: find ./release-files/ -type f -name "linux" -exec chmod +x ./release-files/{} \; | |
- run: ls ./release-files/ | |
- name: Save version to env | |
run: | | |
version=$(<./release-files/version) | |
echo "TM_VERSION=$version" >> $GITHUB_ENV | |
- name: Remove version file | |
run: rm ./release-files/version | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "./release-files/*" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit: master | |
generateReleaseNotes: true | |
skipIfReleaseExists: true | |
allowUpdates: true | |
draft: true | |
tag: ${{ env.TM_VERSION }} | |
publish-on-crates: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: publish cmaze | |
uses: katyo/publish-crates@v2 | |
with: | |
path: ./cmaze | |
registry-token: ${{ secrets.CRATES_IO }} | |
ignore-unpublished-changes: true | |
- name: publish tmaze | |
uses: katyo/publish-crates@v2 | |
with: | |
path: ./tmaze | |
registry-token: ${{ secrets.CRATES_IO }} | |
ignore-unpublished-changes: true | |