diff --git a/.github/workflows/aur.yml b/.github/workflows/aur.yml new file mode 100644 index 0000000..6baf077 --- /dev/null +++ b/.github/workflows/aur.yml @@ -0,0 +1,28 @@ +name: Publish to AUR + +on: + push: + branches: + - master + paths-ignore: + - '**/.gitignore' + - '.vscode/**' + - '**/*.md' + - 'scripts/full-release.sh' + - 'scripts/package-deb.sh' + - 'src/fixtures/**' +jobs: + publish-to-aur: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Archlinux + run: curl -L https://github.com/zaoqi/github-actions-archlinux/raw/master/install.sh | sh + - name: Install dependencies + run: sudo pacman -Syu --noconfirm base-devel git + - name: Configure git + run: | + git config --global user.email "{{ github.actor }}@users.noreply.github.com" + git config --global user.name "{{ github.actor }}" + - name: Publish to AUR + run: ./scripts/publish-aur.sh \ No newline at end of file diff --git a/.github/workflows/release-old.yml b/.github/workflows/release-old.yml deleted file mode 100644 index f07ccef..0000000 --- a/.github/workflows/release-old.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Release new version -on: - workflow_dispatch: - inputs: - version: - description: 'The version number to use' - default: '0.0.0.0' - # Input has to be provided for the workflow to run - required: true -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Validate version number - run: | - # validate version structure - bash -c '[[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1' - # ensure version doesn't already exist - bash -c 'git rev-parse "v${{ github.event.inputs.version }}" >/dev/null 2>&1 && exit 2 || exit 0' - - name: Checkout - uses: actions/checkout@v2.3.3 - with: - submodules: true - - name: Install dependencies - run: sudo apt install nuget mono-complete make - - name: Update version number, and commit - run: | - git config --global user.name "Github Actions" - git config --global user.email "dyc3@users.noreply.github.com" - sed -ri "s/Version\(\"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\"\)/Version\(\"${{ github.event.inputs.version }}\"\)/g" AssemblyInfo.cs - git commit -m "Update version" AssemblyInfo.cs - - name: Build - run: | - nuget restore SteamAuth/SteamAuth/SteamAuth.sln - make - mv build steamguard-cli-v${{ github.event.inputs.version }} - tar -cf steamguard-cli-v${{ github.event.inputs.version }}.tar.gz steamguard-cli-v${{ github.event.inputs.version }} - - name: Tag and push version commit - run: | - git push origin master - git tag -a "v${{ github.event.inputs.version }}" -m "Release v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Upload Build Artifact - uses: actions/upload-artifact@v2.2.0 - with: - name: build - path: steamguard-cli-v${{ github.event.inputs.version }}.tar.gz - deb-package: - runs-on: ubuntu-latest - needs: [build] - steps: - - name: Checkout - uses: actions/checkout@v2.3.3 - - name: Download Build Artifact (tar) - uses: actions/download-artifact@v2.0.5 - with: - name: build - - run: | - tar -xf steamguard-cli-v${{ github.event.inputs.version }}.tar.gz - mv steamguard-cli-v${{ github.event.inputs.version }} build - bash package.sh - - name: Upload deb - uses: actions/upload-artifact@v2.2.0 - with: - name: deb - path: steamguard-cli_${{ github.event.inputs.version }}-0.deb - # TODO: update AUR pkgbuild - draft: - needs: [build, deb-package] - runs-on: ubuntu-latest - steps: - - name: Download Build Artifact (tar) - uses: actions/download-artifact@v2.0.5 - with: - name: build - - name: Download Build Artifact (deb) - uses: actions/download-artifact@v2.0.5 - with: - name: deb - - name: Release Drafter - uses: release-drafter/release-drafter@v5.11.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - name: v${{ github.event.inputs.version }} - tag: v${{ github.event.inputs.version }} - version: ${{ github.event.inputs.version }} - publish: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index f07ccef..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Release new version -on: - workflow_dispatch: - inputs: - version: - description: 'The version number to use' - default: '0.0.0.0' - # Input has to be provided for the workflow to run - required: true -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Validate version number - run: | - # validate version structure - bash -c '[[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1' - # ensure version doesn't already exist - bash -c 'git rev-parse "v${{ github.event.inputs.version }}" >/dev/null 2>&1 && exit 2 || exit 0' - - name: Checkout - uses: actions/checkout@v2.3.3 - with: - submodules: true - - name: Install dependencies - run: sudo apt install nuget mono-complete make - - name: Update version number, and commit - run: | - git config --global user.name "Github Actions" - git config --global user.email "dyc3@users.noreply.github.com" - sed -ri "s/Version\(\"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\"\)/Version\(\"${{ github.event.inputs.version }}\"\)/g" AssemblyInfo.cs - git commit -m "Update version" AssemblyInfo.cs - - name: Build - run: | - nuget restore SteamAuth/SteamAuth/SteamAuth.sln - make - mv build steamguard-cli-v${{ github.event.inputs.version }} - tar -cf steamguard-cli-v${{ github.event.inputs.version }}.tar.gz steamguard-cli-v${{ github.event.inputs.version }} - - name: Tag and push version commit - run: | - git push origin master - git tag -a "v${{ github.event.inputs.version }}" -m "Release v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Upload Build Artifact - uses: actions/upload-artifact@v2.2.0 - with: - name: build - path: steamguard-cli-v${{ github.event.inputs.version }}.tar.gz - deb-package: - runs-on: ubuntu-latest - needs: [build] - steps: - - name: Checkout - uses: actions/checkout@v2.3.3 - - name: Download Build Artifact (tar) - uses: actions/download-artifact@v2.0.5 - with: - name: build - - run: | - tar -xf steamguard-cli-v${{ github.event.inputs.version }}.tar.gz - mv steamguard-cli-v${{ github.event.inputs.version }} build - bash package.sh - - name: Upload deb - uses: actions/upload-artifact@v2.2.0 - with: - name: deb - path: steamguard-cli_${{ github.event.inputs.version }}-0.deb - # TODO: update AUR pkgbuild - draft: - needs: [build, deb-package] - runs-on: ubuntu-latest - steps: - - name: Download Build Artifact (tar) - uses: actions/download-artifact@v2.0.5 - with: - name: build - - name: Download Build Artifact (deb) - uses: actions/download-artifact@v2.0.5 - with: - name: deb - - name: Release Drafter - uses: release-drafter/release-drafter@v5.11.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - name: v${{ github.event.inputs.version }} - tag: v${{ github.event.inputs.version }} - version: ${{ github.event.inputs.version }} - publish: false diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 0280bae..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "SteamAuth"] - path = SteamAuth - url = https://github.com/dyc3/SteamAuth.git diff --git a/scripts/full-release.sh b/scripts/full-release.sh index 8f014b9..9d2f1e9 100755 --- a/scripts/full-release.sh +++ b/scripts/full-release.sh @@ -76,17 +76,3 @@ if [[ $DRY_RUN == false ]]; then fi gh release create "$VERSION" --title "$VERSION" --draft "$BIN_PATH" "./steamguard-cli_$RAW_VERSION-0.deb" fi - -# update PKGBUILD for AUR -if [[ -d "aur" ]]; then - rm -rf aur -fi -git clone ssh://aur@aur.archlinux.org/steamguard-cli-git.git aur -cp PKGBUILD aur/PKGBUILD -cd aur -git commit -m "release $VERSION" PKGBUILD -if [[ $DRY_RUN == false ]]; then - git push - rm -rf aur -fi -cd .. diff --git a/scripts/publish-aur.sh b/scripts/publish-aur.sh new file mode 100644 index 0000000..6c5d4e5 --- /dev/null +++ b/scripts/publish-aur.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -e + +DRY_RUN=true + +POSITIONAL=() +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + --execute) + DRY_RUN=false + shift # past argument + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done + +# prerequisites +if ! command -v makepkg &> /dev/null; then + echo "Error: makepkg is not installed" + exit 1 +fi +if ! command -v git &> /dev/null; then + echo "Error: git is not installed" + exit 2 +fi + + +# get version info +BIN_PATH="target/release/steamguard-cli" +RAW_VERSION="$("$BIN_PATH" --version | cut -d " " -f 2)" +TAGGED_VERSION="$(git tag | grep "^v" | tail -n 1 | tr -d v)" +if [[ "v$RAW_VERSION" != "v$TAGGED_VERSION" ]]; then + echo "Version mismatch: $RAW_VERSION != $TAGGED_VERSION" + exit 10 +fi +VERSION="v$RAW_VERSION" + +# update PKGBUILD for AUR +if [[ -d "aur" ]]; then + rm -rf aur +fi +git clone ssh://aur@aur.archlinux.org/steamguard-cli-git.git aur +cp PKGBUILD aur/PKGBUILD +cd aur +makepkg -si --noconfirm +makepkg --printsrcinfo > .SRCINFO +git commit -m "release $VERSION" PKGBUILD +if [[ $DRY_RUN == false ]]; then + git push + rm -rf aur +fi +cd .. \ No newline at end of file