Skip to content

cleanup worlkflows

cleanup worlkflows #2

Workflow file for this run

---
name: Deploy
on:
push:
tags:
- '*'
workflow_dispatch:
permissions:
contents: write
jobs:
test:
uses: ./.github/workflows/test.yml
with:
branch: main
build:
name: Build and release
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: windows
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get the release version from the tag
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- run: sudo apt -y install musl-dev musl-tools
if: matrix.build == 'linux'
- run: choco install openssl
if: matrix.build == 'windows'
- run: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath
$env:GITHUB_ENV -Append
if: matrix.build == 'windows'
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
binary_name="gbump"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: |-
${{ env.ASSET }}
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
package:
name: PackageCloud
needs:
- build
uses: ./.github/workflows/packagecloud.yml
secrets: inherit