Skip to content

Readme update

Readme update #3

Workflow file for this run

name: Release
permissions:
contents: write
on:
push:
branches:
- main
jobs:
check_release:
runs-on: ubuntu-latest
outputs:
releaseExists: ${{ steps.check_release.outputs.releaseExists }}
steps:
- name: Check if release exists
id: check_release
uses: actions/github-script@v5
with:
script: |
const { owner, repo } = context.repo;
const version = "${{ env.VERSION }}";
const tag = `v${version}`;
let releaseExists = false;
try {
await github.rest.repos.getReleaseByTag({
owner,
repo,
tag,
});
releaseExists = true;
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
return { releaseExists };
release:
needs: check_release
if: ${{ needs.check_release.outputs.releaseExists == 'false' }}
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- arm-unknown-linux-gnueabihf
- powerpc64le-unknown-linux-gnu
- s390x-unknown-linux-gnu
- aarch64-apple-darwin
- x86_64-apple-darwin
runs-on: ${{ (matrix.target == 'aarch64-apple-darwin' || matrix.target == 'x86_64-apple-darwin') && 'macos-latest' || 'ubuntu-latest' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: Package binaries
shell: bash
run: |
cd target/${{ matrix.target }}/release
short_target=$(echo "${{ matrix.target }}" | sed 's/-unknown//')
tar czvf ../../../killport-${short_target}.tar.gz killport
cd -
- name: Extract version from Cargo.toml
id: get_version
run: |
VERSION=$(grep '^version =' Cargo.toml | head -n 1 | awk '{print $3}' | tr -d '"' | tr -d "\n")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Found version: $VERSION"
echo "::set-output name=version::$VERSION"
- name: Create release and upload assets
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
files: 'killport*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CRATES_IO }}