Skip to content

Update package version #1405

Update package version

Update package version #1405

name: "Update package version"
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
update:
name: Update
runs-on: ubuntu-latest
strategy:
matrix:
package:
- an-anime-game-launcher
- an-anime-borb-launcher
- the-honkers-railway-launcher
- honkers-launcher
steps:
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v2
- 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@v23
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Checkout repository
uses: actions/checkout@v4
- name: Get current version
run: |
set -x
currentVersion="$(nix-instantiate --eval -E '
let
aagl = import ./default.nix;
version = aagl.${{ matrix.package }}-unwrapped.version;
in
version
' | tr -d \")"
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@v3
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@v3
with:
name: "${{ matrix.package }}-update.diff"
path: "${{ matrix.package }}-update.diff"
- name: Upload commit artifact
uses: actions/upload-artifact@v3
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
nixPath:
- nixpkgs=channel:nixos-unstable
- nixpkgs=channel:nixpkgs-unstable
# - nixpkgs=channel:nixos-22.11
package:
- an-anime-game-launcher
- an-anime-borb-launcher
- the-honkers-railway-launcher
- honkers-launcher
steps:
- name: Download skip artifact
uses: actions/download-artifact@v3
with:
name: "${{ matrix.package }}-skipped.artifact"
path: "${{ matrix.package }}-skipped.artifact"
- name: Check if build skipped
run: |
echo "skipped=$(cat ${{ matrix.package }}-skipped.artifact/${{ matrix.package }}-skipped.artifact)" >> $GITHUB_ENV
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v2
- 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@v23
with:
nix_path: "${{ matrix.nixPath }}"
- name: Install Cachix
uses: cachix/cachix-action@v12
with:
name: ${{ matrix.cachixName }}
authToken: '${{ env.CACHIX_AUTH_TOKEN }}'
pushFilter: '(-source$|-src$|\.tar\.gz$|\.patch$)'
- name: Download diff artifact
uses: actions/download-artifact@v3
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: Build
run: |
nix-build -A "${{ matrix.package }}"
env:
NIXPKGS_ALLOW_UNFREE: 1
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
- the-honkers-railway-launcher
- honkers-launcher
steps:
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v2
- 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: Download diff artifact
uses: actions/download-artifact@v3
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@v3
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@v5
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 != ''