ci(release): add release please workflow #2
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
# https://sourcegraph.com/github.com/martinohmann/dts/-/blob/.github/workflows/release-please.yml | ||
# https://sourcegraph.com/github.com/kabouzeid/turm/-/blob/.github/workflows/release.yml | ||
# https://github.com/starship/starship/blob/master/.github/workflows/release.yml | ||
name: release please | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- ci/* | ||
env: | ||
CARGO_INCREMENTAL: 0 | ||
jobs: | ||
release_please: | ||
name: Release Please | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'edeneast/tuxmux' | ||
outputs: | ||
release_created: ${{ steps.release.outputs.release_created }} | ||
tag_name: ${{ steps.release.outputs.tag_name }} | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
release-type: rust | ||
bump-minor-pre-major: true | ||
package-name: tuxmux | ||
draft: true | ||
github_build: | ||
name: Build release binaries | ||
needs: release_please | ||
if: ${{ needs.release-please.outputs.release_created == 'true' }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
name: tuxmux-x86_64-unknown-linux-gnu.tar.gz | ||
- target: x86_64-apple-darwin | ||
os: macos-latest | ||
name: tuxmux- x86_64-apple-darwin.tar.gz | ||
runs-on: ${{ matrix.os }} | ||
continue-on-error: true | ||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup | Rust | ||
uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- name: Build | Build [Cargo] | ||
run: cargo build --release --locked --target ${{ matrix.target }} | ||
- name: Post Build | Prepare artifacts | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
tar czvf ../../../${{ matrix.name }} tuxmux | ||
cd - | ||
- name: Release | Upload artifacts | ||
uses: actions/upload-artifact @v3 | ||
with: | ||
name: ${{ matrix.name }} | ||
path: ${{ matrix.name }} | ||
upload_artifacts: | ||
name: Add build artifacts to release | ||
needs: [release_please, github_build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | Artifacts | ||
uses: actions/download-artifact@v3 | ||
- name: Setup | Checksum | ||
run: for file in tuxmux-*/tuxmux-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done | ||
- name: Build | Publish release | ||
run: gh release edit ${{ needs.release_please.outputs.tag_name }} --draft=true --repo=edeneast/tuxmux | ||
env: | ||
GITHUB_TOKEN: ${{ needs.release_please.outputs.tag_name }} | ||
- name: Build | Add artifacts to release | ||
uses: softprops/actios-gh-release@v1 | ||
with: | ||
files: tuxmux-*/tuxmux-* | ||
tag_name: ${{ needs.release_please.outputs.tag_name }} | ||
publish-crate: | ||
needs: release-please | ||
if: ${{ needs.release-please.outputs.release_created || github.events.inputs.force-publish-crate == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup | Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Build | Publish to crates.io | ||
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |