diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b1674d0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,79 @@ +name: release + +on: + push: + tags: + - '*' + +jobs: + build_release: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Rust Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - name: Build and Extract Version + run: | + cargo build --release + echo "::set-output name=version::$(./target/release/snip --version)" + id: version + + - name: Build Artifacts for Different Platforms + run: | + rustup target add x86_64-unknown-linux-gnu + rustup target add x86_64-pc-windows-gnu + rustup target add x86_64-apple-darwin + cargo build --target x86_64-unknown-linux-gnu --release + cargo build --target x86_64-pc-windows-gnu --release + cargo build --target x86_64-apple-darwin --release + + - name: Create Release + uses: actions/create-release@v1 + id: create_release + with: + draft: false + prerelease: false + release_name: ${{ steps.version.outputs.version }} + tag_name: ${{ github.ref }} + body_path: CHANGELOG.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Linux Artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./target/x86_64-unknown-linux-gnu/release/snip + asset_name: snip-linux-x86_64 + asset_content_type: application/octet-stream + + - name: Upload Darwin Artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./target/x86_64-apple-darwin/release/snip + asset_name: snip-darwin-x86_64 + asset_content_type: application/octet-stream + + - name: Upload Windows Artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./target/x86_64-pc-windows-gnu/release/snip.exe + asset_name: snip-windows.exe + asset_content_type: application/octet-stream