Merge pull request #115 from dyc3/aur-automation

AUR automation
This commit is contained in:
Carson McManus 2021-11-14 14:47:07 -05:00 committed by GitHub
commit 9a5b0fbf6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 193 deletions

28
.github/workflows/aur.yml vendored Normal file
View file

@ -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

View file

@ -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

View file

@ -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

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "SteamAuth"]
path = SteamAuth
url = https://github.com/dyc3/SteamAuth.git

View file

@ -76,17 +76,3 @@ if [[ $DRY_RUN == false ]]; then
fi fi
gh release create "$VERSION" --title "$VERSION" --draft "$BIN_PATH" "./steamguard-cli_$RAW_VERSION-0.deb" gh release create "$VERSION" --title "$VERSION" --draft "$BIN_PATH" "./steamguard-cli_$RAW_VERSION-0.deb"
fi 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 ..

57
scripts/publish-aur.sh Normal file
View file

@ -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 ..