-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (99 loc) · 4.1 KB
/
Copy pathupdate.yml
File metadata and controls
116 lines (99 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Check for Updates
on:
schedule:
- cron: "0 8 * * *" # daily at 08:00 UTC
workflow_dispatch:
inputs:
version:
description: "Specific version to update to (without v prefix)"
required: false
permissions:
contents: write
pull-requests: write
jobs:
check-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
allowUnfree = true
env:
NIX_FIRST_BUILD_UID: 400
- name: Check for new version
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT_VERSION=$(grep 'version = "' package.nix | head -1 | sed 's/.*"\(.*\)".*/\1/')
echo "Current version: $CURRENT_VERSION"
if [ -n "${{ github.event.inputs.version }}" ]; then
LATEST_VERSION="${{ github.event.inputs.version }}"
else
LATEST_VERSION=$(gh release view --repo parallel-web/parallel-web-tools --json tagName -q '.tagName' | sed 's/^v//')
fi
if [ -z "$LATEST_VERSION" ]; then
echo "Could not determine latest version"
exit 0
fi
echo "Latest version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "update_needed=true" >> $GITHUB_OUTPUT
else
echo "update_needed=false" >> $GITHUB_OUTPUT
fi
- name: Update version and hashes
if: steps.check.outputs.update_needed == 'true'
run: |
NEW_VERSION="${{ steps.check.outputs.new_version }}"
./scripts/update.sh "$NEW_VERSION"
- name: Verify build
if: steps.check.outputs.update_needed == 'true'
run: NIXPKGS_ALLOW_UNFREE=1 nix build .#parallel-cli --print-build-logs --impure
- name: Create Pull Request
if: steps.check.outputs.update_needed == 'true'
id: create-pr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "update parallel-cli to ${{ steps.check.outputs.new_version }}"
title: "update parallel-cli to ${{ steps.check.outputs.new_version }}"
body: |
Updates parallel-cli from `${{ steps.check.outputs.current_version }}` to `${{ steps.check.outputs.new_version }}`.
**Changes:**
- Version bump in `package.nix`
- Updated SHA256 hashes for all 4 platforms
**Release:** https://github.com/parallel-web/parallel-web-tools/releases/tag/v${{ steps.check.outputs.new_version }}
---
*Auto-generated by the update workflow.*
branch: update/v${{ steps.check.outputs.new_version }}
delete-branch: true
labels: |
dependencies
automated
- name: Enable auto-merge
if: steps.check.outputs.update_needed == 'true' && steps.create-pr.outputs.pull-request-number
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash --delete-branch
- name: Summary
if: always()
run: |
echo "## Update Check" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.check.outputs.update_needed }}" == "true" ]; then
echo "- **Current:** ${{ steps.check.outputs.current_version }}" >> $GITHUB_STEP_SUMMARY
echo "- **New:** ${{ steps.check.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
echo "- PR created with auto-merge enabled" >> $GITHUB_STEP_SUMMARY
else
echo "Already up to date." >> $GITHUB_STEP_SUMMARY
fi