From 29becb5970c3a0dabb99ecafaf909cf649331a25 Mon Sep 17 00:00:00 2001 From: EdenEast Date: Thu, 14 Sep 2023 21:59:41 -0400 Subject: [PATCH 1/3] ci(release): add release please workflow --- .github/workflows/release.yml | 110 ++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..65bc4c0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,110 @@ +# 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 }} + 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 }} From 7e9dbc83a609592d4c0154ae0850c2083fcbac8b Mon Sep 17 00:00:00 2001 From: EdenEast Date: Thu, 14 Sep 2023 23:03:18 -0400 Subject: [PATCH 2/3] ci(release): add permissions to release action --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65bc4c0..7333774 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,9 @@ # https://github.com/starship/starship/blob/master/.github/workflows/release.yml name: release please +permissions: + contents: write + pull-requests: write on: workflow_dispatch: push: From 9b438b5274f45cc1e07fa0dc518236a04f48c9ca Mon Sep 17 00:00:00 2001 From: EdenEast Date: Thu, 14 Sep 2023 23:15:30 -0400 Subject: [PATCH 3/3] ci(release): add force publish and release artifacts --- .github/workflows/release.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7333774..65e7a15 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,10 +8,18 @@ permissions: pull-requests: write on: workflow_dispatch: + inputs: + force-publish-crate: + required: true + type: boolean + description: Publish crate even if no new release was created. + force-publish-packages: + required: true + type: boolean + description: Publish packages even if no new release was created. push: branches: - main - - ci/* env: CARGO_INCREMENTAL: 0 @@ -79,6 +87,7 @@ jobs: upload_artifacts: name: Add build artifacts to release needs: [release_please, github_build] + if: ${{ needs.release-please.outputs.release_created == 'true' || github.event.inputs.force-publish-packages == 'true' }} runs-on: ubuntu-latest steps: - name: Setup | Artifacts @@ -100,7 +109,7 @@ jobs: publish_crate: needs: release_please - if: ${{ needs.release-please.outputs.release_created }} + if: ${{ needs.release-please.outputs.release_created || github.event.inputs.force-publish-crate == 'true' }} runs-on: ubuntu-latest steps: - name: Setup | Checkout