zxczc #12
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: moto release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
release: | |
if: contains(github.event.head_commit.message, 'release') | |
runs-on: windows-latest # Use a Windows runner | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Cargo Registry and Target Directory | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: x86_64-pc-windows-msvc # Target Windows MSVC | |
- name: Determine Release Tag | |
id: release_tag | |
run: echo "RELEASE_TAG=v$(date +'%Y.%m.%d.%H%M%S')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: Create Release Tag and Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
release_name: moto π release ${{ env.RELEASE_TAG }} | |
draft: false | |
prerelease: false | |
- name: Build Rust Project | |
run: | | |
cargo build --release --bin moto | |
- name: Check and list files in release directory | |
run: | | |
$releaseDir = "./target/release/" | |
if (Test-Path $releaseDir/moto.exe) { | |
Write-Output "no.exe exists in the release directory." | |
} else { | |
Write-Output "no.exe does not exist in the release directory." | |
} | |
Write-Output "Listing all files in the release directory:" | |
Get-ChildItem -Path $releaseDir -Recurse | ForEach-Object { | |
Write-Output "$($_.FullName)" | |
} | |
if (-not (Test-Path $releaseDir/moto.exe)) { | |
exit 1 | |
} | |
shell: pwsh | |
- name: Upload Artifacts to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/release/moto.exe | |
asset_name: moto.exe | |
asset_content_type: application/octet-stream |