diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1c855f83 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release Binary + +on: + push: + tags: + - 'v[0-9]+\.[0-9]+\.[0-9]+' + - 'v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: Build release binary + run: cargo build --release + - name: Package binary + id: package + run: | + mkdir -p dist + cp target/release/mdtablefix dist/mdtablefix-linux + version="${GITHUB_REF_NAME#v}" + cd dist + tar -czf "mdtablefix-${version}-linux.tar.gz" mdtablefix-linux + echo "version=${version}" >> "$GITHUB_OUTPUT" + env: + GITHUB_REF_NAME: ${{ github.ref_name }} + - name: Upload to release + uses: softprops/action-gh-release@v1 + with: + files: dist/mdtablefix-${{ steps.package.outputs.version }}-linux.tar.gz + prerelease: ${{ contains(github.ref, '-') }} +