Update main.rs #20
Workflow file for this run
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: ULID Tool Build and Release | |
on: | |
workflow_dispatch: # Manually trigger the workflow | |
pull_request_target: | |
branches: | |
- main | |
types: | |
- closed | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' }} # Allow manual triggering | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 # Add back the checkout step | |
with: | |
ref: ${{ github.ref }} # Checkout the current Git reference, including tags | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Build and Test ULID Tool | |
run: | | |
cd tools/ulid | |
cargo build --release --verbose | |
cargo test --verbose | |
- name: Determine Tag Name | |
id: get_tag | |
run: echo "::set-output name=tag_name::$(git describe --tags --abbrev=0)" | |
- name: Archive Binary | |
run: | | |
cd tools/ulid/target/release | |
zip ulid-${{ steps.get_tag.outputs.tag_name }}.zip ulid | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_tag.outputs.tag_name }} | |
release_name: ULID Release ${{ steps.get_tag.outputs.tag_name }} | |
draft: false | |
prerelease: ${{ startsWith(steps.get_tag.outputs.tag_name, 'v') }} | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./tools/ulid/target/release/ulid-${{ steps.get_tag.outputs.tag_name }}.zip | |
asset_name: ulid-${{ steps.get_tag.outputs.tag_name }}.zip | |
asset_content_type: application/zip |