Skip to content

Update visual-studio-code-insiders-bin #6994

Update visual-studio-code-insiders-bin

Update visual-studio-code-insiders-bin #6994

name: Update visual-studio-code-insiders-bin
on:
workflow_dispatch:
inputs:
force-update:
type: choice
description: "Bump pkgrel if pkgver unchanged"
default: 'no'
options:
- 'yes'
- 'no'
schedule:
# Github recommends avoiding full hours
# See https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
- cron: "12 * * * *" # Hourly at minute 12
concurrency:
group: vscode-insiders
cancel-in-progress: false
env:
PKGNAME: visual-studio-code-insiders-bin
jobs:
do:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
ssh-key: ${{ secrets.SSH_KEY_PRIVATE }}
- name: Calculate pkgver and pkgrel
id: pkg
run: |
version_current=$(awk 'match($0, "^pkgver=([0-9]+)$", arr) {print arr[1]}' ${{ env.PKGNAME }}/PKGBUILD)
pkgrel_current=$(awk 'match($0, "^pkgrel=([0-9]+)$", arr) {print arr[1]}' ${{ env.PKGNAME }}/PKGBUILD)
if [ -z "${version_current}" ]; then
echo "::error ::Could not find current version"
exit 1
fi
version_new=""
lookup=("x64:x86_64" "arm64:aarch64" "armhf:armv7h")
for entry in "${lookup[@]}"; do
arch1=${entry%%:*}
arch2=${entry#*:}
url=$(curl -ILs -o /dev/null -w %{url_effective} 'https://code.visualstudio.com/sha/download?build=insider&os=linux-'${arch1})
version=$(IFS='/' read -ra ADDR <<< $(echo "${url}"); echo "${ADDR[7]}" | sed "s/code-insider-${arch1}-//g" | sed 's/.tar.gz//g' | sed 's/-/./g')
if [ -z "$version" ]; then
echo "::error ::No version found from ${url}"
continue
fi
if [ "${arch1}" == 'x64' ]; then
version_new=$version
fi
sed -i "s|^source_${arch2}=.*$|source_${arch2}=\(code_${arch1}_${version}\.tar\.gz::${url}\)|g" ${{ env.PKGNAME }}/PKGBUILD
done
if [ -z "${version_new}" ]; then
echo "::error ::Could not find new version"
exit 1
fi
if [ "${version_current}" == "${version_new}" ]; then
echo "::notice ::No new version found, still at $version_current"
if [ "${{ github.event.inputs.force-update || 'no' }}" == 'yes' ]; then
pkgrel=$((pkgrel_current + 1))
echo "::notice ::Force update requested, bumping pkgrel to $pkgrel"
echo "new_pkgrel=$pkgrel" >> $GITHUB_OUTPUT
fi
exit 0
fi
echo "::notice ::Version changed $version_current -> $version_new"
echo "new_pkgver=$version_new" >> $GITHUB_OUTPUT
echo "new_pkgrel=1" >> $GITHUB_OUTPUT
- name: Prepare commit message
uses: ./.github/actions/prepare-commit-msg
if: steps.pkg.outputs.new_pkgver != '' || steps.pkg.outputs.new_pkgrel != ''
id: prep
with:
pkgname: ${{ env.PKGNAME }}
new-pkgver: ${{ steps.pkg.outputs.new_pkgver }}
new-pkgrel: ${{ steps.pkg.outputs.new_pkgrel }}
- name: Update PKGBUILD and generate diff
uses: ./.github/actions/updpkgsums
if: steps.prep.outcome == 'success'
id: update
with:
pkgname: ${{ env.PKGNAME }}
new-pkgver: ${{ steps.pkg.outputs.new_pkgver }}
new-pkgrel: ${{ steps.pkg.outputs.new_pkgrel }}
skip-makepkg: 'no'
- name: Configure git and SSH
uses: ./.github/actions/configure-git-ssh
if: steps.update.outcome == 'success'
id: configure
with:
ssh-priv-key: ${{ secrets.SSH_KEY_PRIVATE }}
commit-email: ${{ secrets.GIT_EMAIL }}
commit-user: ${{ secrets.GIT_USER }}
- name: Commit and push to Github
uses: ./.github/actions/commit-and-push
if: steps.configure.outcome == 'success'
id: commit
with:
commit-msg: ${{ steps.prep.outputs.commit-msg }}
- name: Publish to AUR
uses: ./.github/actions/publish-to-aur
if: steps.commit.outcome == 'success'
with:
pkgname: ${{ env.PKGNAME }}
commit-msg: ${{ steps.prep.outputs.commit-msg }}
new-pkgver: ${{ steps.pkg.outputs.new_pkgver }}
new-pkgrel: ${{ steps.pkg.outputs.new_pkgrel }}
commit-email: ${{ secrets.GIT_EMAIL }}
commit-user: ${{ secrets.GIT_USER }}
ssh-priv-key: ${{ secrets.SSH_KEY_PRIVATE }}