|
1 | | -name: Update box32 package |
2 | | - |
3 | | -on: |
4 | | - schedule: |
5 | | - # Run every day at 06:00 UTC |
6 | | - - cron: "0 6 * * *" |
7 | | - workflow_dispatch: {} |
8 | | - |
9 | | -permissions: |
10 | | - contents: write |
11 | | - pull-requests: write |
12 | | - |
13 | | -jobs: |
14 | | - update: |
15 | | - runs-on: ubuntu-latest |
16 | | - |
17 | | - steps: |
18 | | - # ----------------------------------------------------------------------- |
19 | | - # 1. Checkout |
20 | | - # ----------------------------------------------------------------------- |
21 | | - - name: Checkout repository |
22 | | - uses: actions/checkout@v4 |
23 | | - |
24 | | - # ----------------------------------------------------------------------- |
25 | | - # 2. Fetch the latest box64 release tag and resolve its commit SHA |
26 | | - # ----------------------------------------------------------------------- |
27 | | - - name: Get latest box64 release info |
28 | | - id: release |
29 | | - env: |
30 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | | - run: | |
32 | | - LATEST_TAG=$(gh api repos/ptitSeb/box64/releases/latest --jq '.tag_name') |
33 | | - echo "tag=${LATEST_TAG}" >> "$GITHUB_OUTPUT" |
34 | | -
|
35 | | - COMMIT=$(gh api "repos/ptitSeb/box64/git/refs/tags/${LATEST_TAG}" \ |
36 | | - --jq '.object.sha // empty') |
37 | | -
|
38 | | - # Tags may point to a tag object rather than directly to a commit. |
39 | | - if [ -z "$COMMIT" ]; then |
40 | | - COMMIT=$(gh api "repos/ptitSeb/box64/git/tags/$(gh api "repos/ptitSeb/box64/git/refs/tags/${LATEST_TAG}" --jq '.object.sha')" \ |
41 | | - --jq '.object.sha') |
42 | | - fi |
43 | | -
|
44 | | - echo "commit=${COMMIT}" >> "$GITHUB_OUTPUT" |
45 | | -
|
46 | | - # ----------------------------------------------------------------------- |
47 | | - # 3. Compare with the commit currently recorded in pkgs/box32.nix |
48 | | - # ----------------------------------------------------------------------- |
49 | | - - name: Check whether an update is needed |
50 | | - id: check |
51 | | - run: | |
52 | | - CURRENT=$(grep -oP '(?<=version = ")[^"]+' pkgs/box32.nix | head -1) |
53 | | - echo "current=${CURRENT}" >> "$GITHUB_OUTPUT" |
54 | | - if [ "$CURRENT" = "${{ steps.release.outputs.commit }}" ]; then |
55 | | - echo "needed=false" >> "$GITHUB_OUTPUT" |
56 | | - else |
57 | | - echo "needed=true" >> "$GITHUB_OUTPUT" |
58 | | - fi |
59 | | -
|
60 | | - # ----------------------------------------------------------------------- |
61 | | - # 4. Install Nix (only when an update is needed) |
62 | | - # ----------------------------------------------------------------------- |
63 | | - - name: Install Nix |
64 | | - if: steps.check.outputs.needed == 'true' |
65 | | - uses: cachix/install-nix-action@v27 |
66 | | - with: |
67 | | - nix_path: nixpkgs=channel:nixos-unstable |
68 | | - extra_nix_config: | |
69 | | - experimental-features = nix-command flakes |
70 | | -
|
71 | | - # ----------------------------------------------------------------------- |
72 | | - # 5. Compute the new fetchFromGitHub hash |
73 | | - # ----------------------------------------------------------------------- |
74 | | - - name: Compute new hash |
75 | | - if: steps.check.outputs.needed == 'true' |
76 | | - id: hash |
77 | | - run: | |
78 | | - NEW_COMMIT="${{ steps.release.outputs.commit }}" |
79 | | - # nix-prefetch-github prints JSON; extract the "hash" field (SRI format). |
80 | | - HASH=$(nix run nixpkgs#nix-prefetch-github -- \ |
81 | | - ptitSeb box64 \ |
82 | | - --rev "$NEW_COMMIT" \ |
83 | | - --fetch-submodules false \ |
84 | | - 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin)['hash'])") |
85 | | - echo "hash=${HASH}" >> "$GITHUB_OUTPUT" |
86 | | -
|
87 | | - # ----------------------------------------------------------------------- |
88 | | - # 6. Patch pkgs/box32.nix in-place |
89 | | - # ----------------------------------------------------------------------- |
90 | | - - name: Update pkgs/box32.nix |
91 | | - if: steps.check.outputs.needed == 'true' |
92 | | - run: | |
93 | | - NEW_COMMIT="${{ steps.release.outputs.commit }}" |
94 | | - NEW_HASH="${{ steps.hash.outputs.hash }}" |
95 | | - OLD_COMMIT="${{ steps.check.outputs.current }}" |
96 | | -
|
97 | | - # Replace the version (commit SHA) line. |
98 | | - sed -i "s|version = \"${OLD_COMMIT}\";|version = \"${NEW_COMMIT}\";|" pkgs/box32.nix |
99 | | -
|
100 | | - # Replace the hash line (handles both the placeholder and a real hash). |
101 | | - # The hash line always follows the pattern: hash = "sha256-..."; |
102 | | - sed -i -E "s|hash = \"sha256-[^\"]+\";|hash = \"${NEW_HASH}\";|" pkgs/box32.nix |
103 | | -
|
104 | | - # ----------------------------------------------------------------------- |
105 | | - # 7. Verify the derivation evaluates cleanly |
106 | | - # ----------------------------------------------------------------------- |
107 | | - - name: Nix evaluate check |
108 | | - if: steps.check.outputs.needed == 'true' |
109 | | - run: | |
110 | | - nix eval .#packages.aarch64-linux.box32.name --no-warn-dirty |
111 | | -
|
112 | | - # ----------------------------------------------------------------------- |
113 | | - # 8. Open a Pull Request with the changes |
114 | | - # ----------------------------------------------------------------------- |
115 | | - - name: Create Pull Request |
116 | | - if: steps.check.outputs.needed == 'true' |
117 | | - uses: peter-evans/create-pull-request@v6 |
118 | | - with: |
119 | | - token: ${{ secrets.GITHUB_TOKEN }} |
120 | | - branch: "auto-update/box32-${{ steps.release.outputs.tag }}" |
121 | | - commit-message: "pkgs/box32: update to ${{ steps.release.outputs.tag }} (${{ steps.release.outputs.commit }})" |
122 | | - title: "box32: ${{ steps.release.outputs.tag }}" |
123 | | - body: | |
124 | | - Automated update triggered by a new upstream box64 release. |
125 | | -
|
126 | | - - **Tag:** `${{ steps.release.outputs.tag }}` |
127 | | - - **Commit:** `${{ steps.release.outputs.commit }}` |
128 | | - - **Previous commit:** `${{ steps.check.outputs.current }}` |
129 | | -
|
130 | | - Please review the [upstream changelog](https://github.com/ptitSeb/box64/releases/tag/${{ steps.release.outputs.tag }}) before merging. |
131 | | - labels: "automated,dependencies" |
132 | | - delete-branch: true |
| 1 | +# name: Update box32 package |
| 2 | + |
| 3 | +# on: |
| 4 | +# schedule: |
| 5 | +# # Run every day at 06:00 UTC |
| 6 | +# - cron: "0 6 * * *" |
| 7 | +# workflow_dispatch: {} |
| 8 | + |
| 9 | +# permissions: |
| 10 | +# contents: write |
| 11 | +# pull-requests: write |
| 12 | + |
| 13 | +# jobs: |
| 14 | +# update: |
| 15 | +# runs-on: ubuntu-latest |
| 16 | + |
| 17 | +# steps: |
| 18 | +# # ----------------------------------------------------------------------- |
| 19 | +# # 1. Checkout |
| 20 | +# # ----------------------------------------------------------------------- |
| 21 | +# - name: Checkout repository |
| 22 | +# uses: actions/checkout@v4 |
| 23 | + |
| 24 | +# # ----------------------------------------------------------------------- |
| 25 | +# # 2. Fetch the latest box64 release tag and resolve its commit SHA |
| 26 | +# # ----------------------------------------------------------------------- |
| 27 | +# - name: Get latest box64 release info |
| 28 | +# id: release |
| 29 | +# env: |
| 30 | +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | +# run: | |
| 32 | +# LATEST_TAG=$(gh api repos/ptitSeb/box64/releases/latest --jq '.tag_name') |
| 33 | +# echo "tag=${LATEST_TAG}" >> "$GITHUB_OUTPUT" |
| 34 | + |
| 35 | +# COMMIT=$(gh api "repos/ptitSeb/box64/git/refs/tags/${LATEST_TAG}" \ |
| 36 | +# --jq '.object.sha // empty') |
| 37 | + |
| 38 | +# # Tags may point to a tag object rather than directly to a commit. |
| 39 | +# if [ -z "$COMMIT" ]; then |
| 40 | +# COMMIT=$(gh api "repos/ptitSeb/box64/git/tags/$(gh api "repos/ptitSeb/box64/git/refs/tags/${LATEST_TAG}" --jq '.object.sha')" \ |
| 41 | +# --jq '.object.sha') |
| 42 | +# fi |
| 43 | + |
| 44 | +# echo "commit=${COMMIT}" >> "$GITHUB_OUTPUT" |
| 45 | + |
| 46 | +# # ----------------------------------------------------------------------- |
| 47 | +# # 3. Compare with the commit currently recorded in pkgs/box32.nix |
| 48 | +# # ----------------------------------------------------------------------- |
| 49 | +# - name: Check whether an update is needed |
| 50 | +# id: check |
| 51 | +# run: | |
| 52 | +# CURRENT=$(grep -oP '(?<=version = ")[^"]+' pkgs/box32.nix | head -1) |
| 53 | +# echo "current=${CURRENT}" >> "$GITHUB_OUTPUT" |
| 54 | +# if [ "$CURRENT" = "${{ steps.release.outputs.commit }}" ]; then |
| 55 | +# echo "needed=false" >> "$GITHUB_OUTPUT" |
| 56 | +# else |
| 57 | +# echo "needed=true" >> "$GITHUB_OUTPUT" |
| 58 | +# fi |
| 59 | + |
| 60 | +# # ----------------------------------------------------------------------- |
| 61 | +# # 4. Install Nix (only when an update is needed) |
| 62 | +# # ----------------------------------------------------------------------- |
| 63 | +# - name: Install Nix |
| 64 | +# if: steps.check.outputs.needed == 'true' |
| 65 | +# uses: cachix/install-nix-action@v27 |
| 66 | +# with: |
| 67 | +# nix_path: nixpkgs=channel:nixos-unstable |
| 68 | +# extra_nix_config: | |
| 69 | +# experimental-features = nix-command flakes |
| 70 | + |
| 71 | +# # ----------------------------------------------------------------------- |
| 72 | +# # 5. Compute the new fetchFromGitHub hash |
| 73 | +# # ----------------------------------------------------------------------- |
| 74 | +# - name: Compute new hash |
| 75 | +# if: steps.check.outputs.needed == 'true' |
| 76 | +# id: hash |
| 77 | +# run: | |
| 78 | +# NEW_COMMIT="${{ steps.release.outputs.commit }}" |
| 79 | +# # nix-prefetch-github prints JSON; extract the "hash" field (SRI format). |
| 80 | +# HASH=$(nix run nixpkgs#nix-prefetch-github -- \ |
| 81 | +# ptitSeb box64 \ |
| 82 | +# --rev "$NEW_COMMIT" \ |
| 83 | +# --fetch-submodules false \ |
| 84 | +# 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin)['hash'])") |
| 85 | +# echo "hash=${HASH}" >> "$GITHUB_OUTPUT" |
| 86 | + |
| 87 | +# # ----------------------------------------------------------------------- |
| 88 | +# # 6. Patch pkgs/box32.nix in-place |
| 89 | +# # ----------------------------------------------------------------------- |
| 90 | +# - name: Update pkgs/box32.nix |
| 91 | +# if: steps.check.outputs.needed == 'true' |
| 92 | +# run: | |
| 93 | +# NEW_COMMIT="${{ steps.release.outputs.commit }}" |
| 94 | +# NEW_HASH="${{ steps.hash.outputs.hash }}" |
| 95 | +# OLD_COMMIT="${{ steps.check.outputs.current }}" |
| 96 | + |
| 97 | +# # Replace the version (commit SHA) line. |
| 98 | +# sed -i "s|version = \"${OLD_COMMIT}\";|version = \"${NEW_COMMIT}\";|" pkgs/box32.nix |
| 99 | + |
| 100 | +# # Replace the hash line (handles both the placeholder and a real hash). |
| 101 | +# # The hash line always follows the pattern: hash = "sha256-..."; |
| 102 | +# sed -i -E "s|hash = \"sha256-[^\"]+\";|hash = \"${NEW_HASH}\";|" pkgs/box32.nix |
| 103 | + |
| 104 | +# # ----------------------------------------------------------------------- |
| 105 | +# # 7. Verify the derivation evaluates cleanly |
| 106 | +# # ----------------------------------------------------------------------- |
| 107 | +# - name: Nix evaluate check |
| 108 | +# if: steps.check.outputs.needed == 'true' |
| 109 | +# run: | |
| 110 | +# nix eval .#packages.aarch64-linux.box32.name --no-warn-dirty |
| 111 | + |
| 112 | +# # ----------------------------------------------------------------------- |
| 113 | +# # 8. Open a Pull Request with the changes |
| 114 | +# # ----------------------------------------------------------------------- |
| 115 | +# - name: Create Pull Request |
| 116 | +# if: steps.check.outputs.needed == 'true' |
| 117 | +# uses: peter-evans/create-pull-request@v6 |
| 118 | +# with: |
| 119 | +# token: ${{ secrets.GITHUB_TOKEN }} |
| 120 | +# branch: "auto-update/box32-${{ steps.release.outputs.tag }}" |
| 121 | +# commit-message: "pkgs/box32: update to ${{ steps.release.outputs.tag }} (${{ steps.release.outputs.commit }})" |
| 122 | +# title: "box32: ${{ steps.release.outputs.tag }}" |
| 123 | +# body: | |
| 124 | +# Automated update triggered by a new upstream box64 release. |
| 125 | + |
| 126 | +# - **Tag:** `${{ steps.release.outputs.tag }}` |
| 127 | +# - **Commit:** `${{ steps.release.outputs.commit }}` |
| 128 | +# - **Previous commit:** `${{ steps.check.outputs.current }}` |
| 129 | + |
| 130 | +# Please review the [upstream changelog](https://github.com/ptitSeb/box64/releases/tag/${{ steps.release.outputs.tag }}) before merging. |
| 131 | +# labels: "automated,dependencies" |
| 132 | +# delete-branch: true |
0 commit comments