Skip to content

Commit 729fc86

Browse files
kubajanuszCopilot
andcommitted
chore: add github copilot nix package
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 parents  commit 729fc86

13 files changed

Lines changed: 1228 additions & 0 deletions

.github/REPOSITORY_SETTINGS.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Repository Settings Configuration
2+
3+
This repository requires specific GitHub settings to enable automated update pull requests.
4+
5+
## Required Settings
6+
7+
### GitHub Actions Permissions
8+
9+
1. Navigate to Settings -> Actions -> General.
10+
2. Under "Workflow permissions":
11+
- Select **Read and write permissions**.
12+
- Check **Allow GitHub Actions to create and approve pull requests**.
13+
3. Click Save.
14+
15+
### Auto-merge
16+
17+
1. Navigate to Settings -> General.
18+
2. Under "Pull Requests", check **Allow auto-merge**.
19+
3. Click Save.
20+
21+
These settings allow `update-github-copilot-cli.yml` to create update pull requests and enable auto-merge after CI passes.
22+
23+
## Verification
24+
25+
```bash
26+
gh workflow run "Update GitHub Copilot CLI Version"
27+
gh run list --workflow="Update GitHub Copilot CLI Version"
28+
```

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
day: "saturday"
8+
time: "09:00"
9+
labels:
10+
- "dependencies"
11+
- "automated"
12+
commit-message:
13+
prefix: "ci"
14+
open-pull-requests-limit: 5

.github/workflows/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
workflow_run:
10+
workflows: ["Update GitHub Copilot CLI Version"]
11+
types: [completed]
12+
branches: [main]
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest, macos-latest]
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
30+
- name: Install Nix
31+
uses: cachix/install-nix-action@ab739621df7a23f52766f9ccc97f38da6b7af14f # v31.10.5
32+
with:
33+
nix_path: nixpkgs=channel:nixos-unstable
34+
extra_nix_config: |
35+
experimental-features = nix-command flakes
36+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
37+
env:
38+
NIX_FIRST_BUILD_UID: 400
39+
40+
- name: Check flake
41+
run: nix flake check --print-build-logs
42+
43+
- name: Build github-copilot-cli
44+
run: nix build .#github-copilot-cli -o result --print-build-logs
45+
46+
- name: Verify package contents
47+
run: test -x ./result/bin/copilot
48+
49+
- name: Run basic functionality test
50+
run: ./result/bin/copilot --version
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Create Version Tag
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build"]
6+
types: [completed]
7+
branches: [main]
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
create-tag:
14+
if: github.event.workflow_run.conclusion == 'success'
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Extract version
24+
id: version
25+
run: |
26+
VERSION=$(sed -n 's/.*"version": "\([^"]*\)".*/\1/p' sources.json | head -1)
27+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
28+
echo "major=${VERSION%%.*}" >> "$GITHUB_OUTPUT"
29+
30+
- name: Check if version tag exists
31+
id: check-tag
32+
run: |
33+
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
34+
echo "exists=true" >> "$GITHUB_OUTPUT"
35+
else
36+
echo "exists=false" >> "$GITHUB_OUTPUT"
37+
fi
38+
39+
- name: Configure git
40+
run: |
41+
git config user.name "github-actions[bot]"
42+
git config user.email "github-actions[bot]@users.noreply.github.com"
43+
44+
- name: Create version tag
45+
if: steps.check-tag.outputs.exists == 'false'
46+
run: |
47+
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
48+
git push origin "v${{ steps.version.outputs.version }}"
49+
50+
- name: Update moving tags
51+
run: |
52+
VERSION="${{ steps.version.outputs.version }}"
53+
MAJOR="${{ steps.version.outputs.major }}"
54+
55+
git push origin :refs/tags/latest 2>/dev/null || true
56+
git push origin ":refs/tags/v$MAJOR" 2>/dev/null || true
57+
git tag -d latest 2>/dev/null || true
58+
git tag -d "v$MAJOR" 2>/dev/null || true
59+
60+
git tag -a latest -m "Latest release: v$VERSION"
61+
git tag -a "v$MAJOR" -m "Latest v$MAJOR release: v$VERSION"
62+
git push origin latest "v$MAJOR"
63+
64+
- name: Summary
65+
run: |
66+
echo "## Tag Summary" >> "$GITHUB_STEP_SUMMARY"
67+
echo "" >> "$GITHUB_STEP_SUMMARY"
68+
echo "| Tag | Points To |" >> "$GITHUB_STEP_SUMMARY"
69+
echo "| --- | --- |" >> "$GITHUB_STEP_SUMMARY"
70+
echo "| v${{ steps.version.outputs.version }} | $(git rev-parse --short HEAD) |" >> "$GITHUB_STEP_SUMMARY"
71+
echo "| v${{ steps.version.outputs.major }} | v${{ steps.version.outputs.version }} |" >> "$GITHUB_STEP_SUMMARY"
72+
echo "| latest | v${{ steps.version.outputs.version }} |" >> "$GITHUB_STEP_SUMMARY"
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Update GitHub Copilot CLI Version
2+
3+
on:
4+
schedule:
5+
- cron: "0 * * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
check-and-update:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Install Nix
23+
uses: cachix/install-nix-action@ab739621df7a23f52766f9ccc97f38da6b7af14f # v31.10.5
24+
with:
25+
nix_path: nixpkgs=channel:nixos-unstable
26+
extra_nix_config: |
27+
experimental-features = nix-command flakes
28+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
29+
env:
30+
NIX_FIRST_BUILD_UID: 400
31+
32+
- name: Check for updates
33+
id: check
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
run: |
37+
CURRENT_VERSION=$(sed -n 's/.*"version": "\([^"]*\)".*/\1/p' sources.json | head -1)
38+
LATEST_VERSION=$(./scripts/update-version.sh --latest-version)
39+
40+
echo "current=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
41+
echo "latest=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
42+
43+
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
44+
echo "update_needed=false" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "update_needed=true" >> "$GITHUB_OUTPUT"
47+
fi
48+
49+
- name: Update version and hashes
50+
if: steps.check.outputs.update_needed == 'true'
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: ./scripts/update-version.sh --version "${{ steps.check.outputs.latest }}"
54+
55+
- name: Create Pull Request
56+
if: steps.check.outputs.update_needed == 'true'
57+
id: create-pr
58+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
59+
with:
60+
token: ${{ secrets.GITHUB_TOKEN }}
61+
commit-message: "chore: update github-copilot-cli to version ${{ steps.check.outputs.latest }}"
62+
title: "chore: update github-copilot-cli to version ${{ steps.check.outputs.latest }}"
63+
body: |
64+
## Automated GitHub Copilot CLI Update
65+
66+
This PR updates GitHub Copilot CLI from version `${{ steps.check.outputs.current }}` to `${{ steps.check.outputs.latest }}`.
67+
68+
### Changes
69+
- Updated `sources.json` version and per-platform release hashes
70+
- Updated `flake.lock`
71+
- Verified the package build
72+
73+
To test locally:
74+
```bash
75+
nix build
76+
./result/bin/copilot --version
77+
```
78+
79+
This PR was automatically generated by the update workflow.
80+
branch: update-github-copilot-cli-${{ steps.check.outputs.latest }}
81+
delete-branch: true
82+
labels: |
83+
dependencies
84+
automated
85+
86+
- name: Enable Auto-Merge
87+
if: steps.check.outputs.update_needed == 'true' && steps.create-pr.outputs.pull-request-number
88+
env:
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: gh pr merge "${{ steps.create-pr.outputs.pull-request-number }}" --auto --squash --delete-branch
91+
92+
- name: Summary
93+
if: always()
94+
run: |
95+
echo "## Update Summary" >> "$GITHUB_STEP_SUMMARY"
96+
echo "" >> "$GITHUB_STEP_SUMMARY"
97+
echo "- **Current Version:** ${{ steps.check.outputs.current }}" >> "$GITHUB_STEP_SUMMARY"
98+
echo "- **Latest Version:** ${{ steps.check.outputs.latest }}" >> "$GITHUB_STEP_SUMMARY"
99+
echo "" >> "$GITHUB_STEP_SUMMARY"
100+
101+
if [ "${{ steps.check.outputs.update_needed }}" = "true" ]; then
102+
echo "Update pull request created." >> "$GITHUB_STEP_SUMMARY"
103+
else
104+
echo "Already up to date." >> "$GITHUB_STEP_SUMMARY"
105+
fi

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/result
2+
result
3+
*.qcow2
4+
.direnv/
5+
.envrc

0 commit comments

Comments
 (0)