Skip to content

Update package version #1972

Update package version

Update package version #1972

name: "Update package version"
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
update:
name: Update
runs-on: ubuntu-latest
strategy:
matrix:
package:
- an-anime-borb-launcher
- an-anime-game-launcher
- anime-games-launcher
- honkers-launcher
- the-honkers-railway-launcher
steps:
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Pass all secrets to next steps
run: |
while read -rd $'' line; do echo "$line" >> $GITHUB_ENV; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.key)<<EOF\n\(.value)\nEOF\u0000")[]' )
while read -r line; do echo "::add-mask::$line"; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.value)\u0000")[]' )
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
- name: Install Nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Checkout repository
uses: actions/checkout@v4
- name: Get current version
run: |
set -x
currentVersion="$(nix eval --impure --raw --expr "
let
flake = builtins.getFlake \"path:$(pwd)/.\";
in flake.packages.x86_64-linux.${{ matrix.package }}.unwrapped.version
")"
echo "current-version=$currentVersion" >> $GITHUB_ENV
- name: Check for new release
run: |
set -x
latestVersion="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --tags --sort='v:refname' \
"https://github.com/an-anime-team/${{ matrix.package }}" | \
awk 'END {match($2, /([^/]+)$/, m); print m[0]}')"
echo "latest-version=$latestVersion" >> $GITHUB_ENV
- name: Update package
if: ${{ env.current-version != env.latest-version }}
run: |
nix shell nixpkgs#nix-update -c nix-update "${{ matrix.package }}-unwrapped" --flake --version=${{ env.latest-version }}
- name: Create diff
id: diff
run: |
set -x
git diff --oneline --graph > ${{ matrix.package }}-update.diff
if [[ "$(<${{ matrix.package }}-update.diff)" == "" ]]; then
echo "skipped=yes" >> $GITHUB_OUTPUT
echo "skipped=yes" > "${{ matrix.package }}-skipped.artifact"
else
echo "skipped=no" >> $GITHUB_OUTPUT
echo "skipped=no" > "${{ matrix.package }}-skipped.artifact"
fi
- name: Create commit message
if: ${{ env.current-version != env.latest-version }}
id: commit-message
run: |
echo "${{ matrix.package }}: ${{ env.current-version }} -> ${{ env.latest-version }}" >> "${{ matrix.package }}-commit.artifact"
- name: Upload skip artifact
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.package }}-skipped.artifact"
path: "${{ matrix.package }}-skipped.artifact"
- name: Upload diff artifact
if: ${{ steps.diff.outputs.skipped == 'no' }}
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.package }}-update.diff"
path: "${{ matrix.package }}-update.diff"
- name: Upload commit artifact
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.package }}-commit.artifact"
path: "${{ matrix.package }}-commit.artifact"
build:
name: Build
needs: update
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cachixName:
- ezkea
nixpkgs:
- nixos-unstable
# - nixpkgs-unstable
- nixos-23.11
- pinned
package:
- an-anime-game-launcher
- an-anime-borb-launcher
- anime-games-launcher
- the-honkers-railway-launcher
- honkers-launcher
steps:
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Pass all secrets to next steps
run: |
while read -rd $'' line; do echo "$line" >> $GITHUB_ENV; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.key)<<EOF\n\(.value)\nEOF\u0000")[]' )
while read -r line; do echo "::add-mask::$line"; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.value)\u0000")[]' )
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v25
- name: Install Cachix
uses: cachix/cachix-action@v14
with:
name: ${{ matrix.cachixName }}
authToken: '${{ env.CACHIX_AUTH_TOKEN }}'
pushFilter: '(-source$|-src$|\.tar\.gz$|\.patch$)'
- name: Download diff artifact
uses: actions/download-artifact@v4
with:
name: "${{ matrix.package }}-update.diff"
path: "${{ matrix.package }}-update.diff"
- name: Check for update artifact
run: |
[[ -f "${{ matrix.package}}-update.diff/${{ matrix.package }}-update.diff" ]] || exit 1
- name: Apply diff
run: |
git apply "${{ matrix.package }}-update.diff/${{ matrix.package }}-update.diff"
- name: Build
id: build
run: |
if [[ ${{ matrix.nixpkgs }} == "pinned" ]]; then
nix build --accept-flake-config -L ".#${{ matrix.package }}"
else
nix build \
--accept-flake-config \
--print-build-logs \
--override-input nixpkgs "github:NixOS/nixpkgs/${{ matrix.nixpkgs }}" \
".#${{ matrix.package }}"
fi
env:
NIXPKGS_ALLOW_UNFREE: 1
- name: Create success artifact
if: steps.build.outcome == 'success'
run: |
echo "yes" >> "${{ matrix.package }}-${{ matrix.nixpkgs }}-success.artifact"
- name: Upload success artifact
uses: actions/upload-artifact@v4
if: steps.build.outcome == 'success'
with:
name: "${{ matrix.package }}-${{ matrix.nixpkgs }}-success.artifact"
path: "${{ matrix.package }}-${{ matrix.nixpkgs }}-success.artifact"
pr:
name: Make PR
if: ${{ ! cancelled() }}
needs: [update, build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- an-anime-game-launcher
- an-anime-borb-launcher
- anime-games-launcher
- the-honkers-railway-launcher
- honkers-launcher
steps:
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Pass all secrets to next steps
run: |
while read -rd $'' line; do echo "$line" >> $GITHUB_ENV; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.key)<<EOF\n\(.value)\nEOF\u0000")[]' )
while read -r line; do echo "::add-mask::$line"; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.value)\u0000")[]' )
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: "${{ matrix.package }}-nixos-unstable-success.artifact"
path: "${{ matrix.package }}-nixos-unstable-success.artifact"
# - uses: actions/download-artifact@v4
# with:
# name: "${{ matrix.package }}-nixpkgs-unstable-success.artifact"
# path: "${{ matrix.package }}-nixpkgs-unstable-success.artifact"
- uses: actions/download-artifact@v4
with:
name: "${{ matrix.package }}-nixos-23.11-success.artifact"
path: "${{ matrix.package }}-nixos-23.11-success.artifact"
- uses: actions/download-artifact@v4
with:
name: "${{ matrix.package }}-pinned-success.artifact"
path: "${{ matrix.package }}-pinned-success.artifact"
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download diff artifact
uses: actions/download-artifact@v4
with:
name: "${{ matrix.package }}-update.diff"
path: "${{ matrix.package }}-update.diff"
- name: Apply diff
run: |
git apply "${{ matrix.package }}-update.diff/${{ matrix.package }}-update.diff"
- name: Download commit artifact
uses: actions/download-artifact@v4
with:
name: "${{ matrix.package }}-commit.artifact"
path: "${{ matrix.package }}-commit.artifact"
- run: |
echo "commit-message=$(cat ${{ matrix.package }}-commit.artifact/${{ matrix.package }}-commit.artifact)" >> $GITHUB_ENV
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
commit-message: ${{ env.commit-message }}
title: ${{ env.commit-message }}
body: |
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: "update-${{ matrix.package }}"
- name: Get workflow conclusion
uses: technote-space/workflow-conclusion-action@v3.0
- name: Send notification
uses: yanzay/notify-telegram@v0.1.0
with:
chat: ${{ env.NOTIFICATION_CHAT_ID }}
token: ${{ env.NOTIFICATION_TOKEN }}
status: ${{ env.WORKFLOW_CONCLUSION }}
if: needs.update.outputs.commit-message != ''