-
Notifications
You must be signed in to change notification settings - Fork 8
157 lines (143 loc) · 4.94 KB
/
release-nu-image.yaml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Build Nushell Release Images
on:
push:
branches:
- main
paths:
- docker
schedule:
- cron: '15 2 * * 2,5' # Run at 02:15 AM UTC for Tuesday and Friday
workflow_dispatch:
jobs:
build-and-push-Nu:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
base: [debian, alpine]
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Set up Nushell
uses: hustcer/setup-nu@v3
with:
check-latest: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Set tag & labels for ${{ github.ref }}"
shell: nu {0}
run: |
let tagName = http get https://api.github.com/repos/nushell/nushell/releases
| sort-by -r created_at | select tag_name | get tag_name.0
git remote set-url origin https://github.com/nushell/nushell.git
git fetch origin -p o+e> /dev/null
let SHA = git rev-list -n 1 $tagName | str substring 0..7
$'BUILD_REF=($SHA)(char nl)' o>> $env.GITHUB_ENV
$'NU_VERSION=($tagName)(char nl)' o>> $env.GITHUB_ENV
$'BUILD_DATE=(date now | format date %Y-%m-%dT%H:%M:%SZ)(char nl)' o>> $env.GITHUB_ENV
- name: Build Debian Test Image
uses: docker/build-push-action@v6
if: ${{ matrix.base == 'debian' }}
env:
DOCKER_BUILD_SUMMARY: false
with:
push: false
load: true
context: ./docker
file: ./docker/debian.Dockerfile
tags: nushell-debian-test-image
- name: Test Debian Image
if: ${{ matrix.base == 'debian' }}
run: |
echo "## Debian Container Test Results" >> $GITHUB_STEP_SUMMARY
docker run --rm \
-v "$(pwd)/docker:/work" \
--env GITHUB_ACTIONS=${{ env.GITHUB_ACTIONS }} \
nushell-debian-test-image -c /work/test_docker.nu \
>> $GITHUB_STEP_SUMMARY
- name: Build and Push Debian Image
uses: docker/build-push-action@v6
if: ${{ matrix.base == 'debian' }}
with:
push: true
provenance: false
context: ./docker
file: ./docker/debian.Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
# platforms: linux/amd64,linux/arm64,linux/riscv64
build-args: |
BUILD_REF=${{ env.BUILD_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}
NU_VERSION=${{ env.NU_VERSION }}
tags: |
ghcr.io/nushell/nushell:latest-bookworm
ghcr.io/nushell/nushell:${{ env.NU_VERSION }}-bookworm
- name: Build Alpine Test Image
uses: docker/build-push-action@v6
if: ${{ matrix.base == 'alpine' }}
env:
DOCKER_BUILD_SUMMARY: false
with:
push: false
load: true
context: ./docker
file: ./docker/Dockerfile
tags: nushell-alpine-test-image
- name: Test Alpine Image
if: ${{ matrix.base == 'alpine' }}
run: |
echo "## Alpine Container Test Results" >> $GITHUB_STEP_SUMMARY
docker run --rm \
-v "$(pwd)/docker:/work" \
--env GITHUB_ACTIONS=${{ env.GITHUB_ACTIONS }} \
nushell-alpine-test-image -c /work/test_docker.nu \
>> $GITHUB_STEP_SUMMARY
- name: Build and Push Alpine Image
uses: docker/build-push-action@v6
if: ${{ matrix.base == 'alpine' }}
with:
push: true
provenance: false
platforms: linux/amd64,linux/arm64,linux/arm/v7
context: ./docker
file: ./docker/Dockerfile
build-args: |
BUILD_REF=${{ env.BUILD_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}
NU_VERSION=${{ env.NU_VERSION }}
tags: |
ghcr.io/nushell/nushell:latest
ghcr.io/nushell/nushell:latest-alpine
ghcr.io/nushell/nushell:${{ env.NU_VERSION }}
ghcr.io/nushell/nushell:${{ env.NU_VERSION }}-alpine
cleanup:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: build-and-push-Nu
steps:
- name: Delete all containers from repository without tags
uses: Chizkiyahu/delete-untagged-ghcr-action@v4
with:
owner_type: user
untagged_only: true
package_name: 'nushell'
repository_owner: 'nushell'
repository: 'nushell/nushell'
token: ${{ secrets.GITHUB_TOKEN }}
except_untagged_multiplatform: true