-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from auyer/release-workflow-and-deb-package
Automatic Release Workflow with DEB and RPM packages
- Loading branch information
Showing
2 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- v* | ||
branches: | ||
- release/* | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
name: "Build and Publish Release" | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: SET CURRENT_VERSION tag | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
branchName=$(echo $GITHUB_REF | sed 's/refs\/tags\///' ) | ||
# variable CURRENT_VERSION should not have the "v" used in the branch name | ||
echo "CURRENT_VERSION=$(echo $branchName | sed 's/v//' )" >> $GITHUB_ENV | ||
- name: SET CURRENT_VERSION branch | ||
if: startsWith(github.ref, 'refs/heads/') | ||
run: | | ||
branchName=$(echo $GITHUB_REF | sed 's/refs\/heads\/release\///') | ||
# variable CURRENT_VERSION should not have the "v" used in the tag | ||
echo "CURRENT_VERSION=$(echo $branchName | sed 's/v//' )" >> $GITHUB_ENV | ||
- name: Update local toolchain | ||
run: | | ||
rustup update | ||
rustup component add clippy | ||
rustup install stable | ||
- name: Install cargo-deb (generate DEB package) | ||
run: cargo install cargo-deb | ||
|
||
- name: Install Alien for RPM conversion | ||
run: | | ||
sudo apt-get update -y | ||
sudo apt-get install -y alien dpkg-dev debhelper build-essential | ||
- name: Run cargo publish libprotonup | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
run: | | ||
# retrieve available versions in crates.io api to skip upload if it was published already | ||
published_versions=$( curl 'https://crates.io/api/v1/crates/libprotonup' -H 'Accept: */*' | jq '.versions[].num' ) | ||
exists=false | ||
if [[ ${published_versions[@]} =~ $CURRENT_VERSION ]] | ||
then | ||
exists=true | ||
fi | ||
if ! ( $exists ) ; then | ||
cargo publish -p libprotonup | ||
fi | ||
- name: Run cargo build | ||
run: cargo build --release | ||
|
||
- name: Run cargo-deb to build a debian package | ||
run: cargo-deb -p protonup-rs --compress-type gzip --deb-version $CURRENT_VERSION | ||
|
||
- name: Run Alient to convert the DEB package into a RPM package | ||
run: | | ||
cd target/debian | ||
alien -k --to-rpm protonup-rs_${{ env.CURRENT_VERSION }}_amd64.deb | ||
- name: Upload DEB package to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: target/debian/protonup-rs_${{ env.CURRENT_VERSION }}_amd64.deb | ||
asset_name: protonup-rs_${{ env.CURRENT_VERSION }}-1_amd64.deb | ||
tag: v${{ env.CURRENT_VERSION }} | ||
overwrite: true | ||
draft: true | ||
|
||
- name: Upload RPM package to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: target/debian/protonup-rs-${{ env.CURRENT_VERSION }}-1.x86_64.rpm | ||
asset_name: protonup-rs_${{ env.CURRENT_VERSION }}-1.x86_64.rpm | ||
tag: v${{ env.CURRENT_VERSION }} | ||
overwrite: true | ||
draft: true | ||
|
||
- name: Compress binary release artefacts | ||
run: | | ||
cd ./target/release | ||
zip protonup-rs-linux-amd64.zip protonup-rs | ||
tar -czvf protonup-rs-linux-amd64.tar.gz protonup-rs | ||
- name: Upload Tar gzed binaries to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: target/release/protonup-rs-linux-amd64.tar.gz | ||
asset_name: protonup-rs-linux-amd64.tar.gz | ||
tag: v${{ env.CURRENT_VERSION }} | ||
overwrite: true | ||
draft: true | ||
|
||
- name: Upload Ziped binaries to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: target/release/protonup-rs-linux-amd64.zip | ||
asset_name: protonup-rs-linux-amd64.zip | ||
tag: v${{ env.CURRENT_VERSION }} | ||
overwrite: true | ||
draft: true | ||
|
||
- name: Run cargo publish binary | ||
env: | ||
# This can help you tagging the github repository | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# This can help you publish to crates.io | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
run: | | ||
# retrieve available versions in crates.io api to skip upload if it was published already | ||
published_versions=$( curl 'https://crates.io/api/v1/crates/Protonup-rs' -H 'Accept: */*' | jq '.versions[].num' ) | ||
exists=false | ||
if [[ ${published_versions[@]} =~ $(echo $CURRENT_VERSION | sed 's/v//' ) ]] | ||
then | ||
exists=true | ||
fi | ||
if ! ( $exists ) ; then | ||
cargo publish -p protonup-rs | ||
fi | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,18 @@ readme = "../README.md" | |
|
||
description = "TUI Program for Custom Proton Download and installation written in rust" | ||
|
||
[package.metadata.deb] | ||
maintainer = "Auyer <[email protected]>" | ||
copyright = "2024, Auyer <[email protected]>" | ||
extended-description = "TUI Program used to download, install and manage custom Proton/Wine distributions for Steam and Lutris." | ||
depends = "$auto" | ||
section = "utility" | ||
priority = "optional" | ||
assets = [ | ||
["target/release/protonup-rs", "usr/bin/", "755"], | ||
["../README.md", "usr/share/doc/protonup-rs/README", "644"], | ||
] | ||
|
||
[dependencies] | ||
|
||
anyhow = "1.0" | ||
|