Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9cd2f31

Browse files
committed
ci: add action to push chocolatey package
1 parent df89e2c commit 9cd2f31

File tree

6 files changed

+96
-0
lines changed

6 files changed

+96
-0
lines changed

.github/actions/chocolatey/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM alpine:latest
2+
3+
ARG CHOCOVERSION=1.1.0
4+
5+
RUN apk add --no-cache bash ca-certificates git \
6+
&& apk --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing add mono mono-dev \
7+
&& cert-sync /etc/ssl/certs/ca-certificates.crt \
8+
&& wget "https://github.com/chocolatey/choco/archive/${CHOCOVERSION}.tar.gz" -O- | tar -xzf - \
9+
&& cd choco-"${CHOCOVERSION}" \
10+
&& chmod +x build.sh zip.sh \
11+
&& ./build.sh -v \
12+
&& mv ./code_drop/chocolatey/console /opt/chocolatey \
13+
&& mkdir -p /opt/chocolatey/lib \
14+
&& rm -rf /choco-"${CHOCOVERSION}" \
15+
&& apk del mono-dev \
16+
&& rm -rf /var/cache/apk/*
17+
18+
ENV ChocolateyInstall=/opt/chocolatey
19+
COPY entrypoint.sh /entrypoint.sh
20+
ENTRYPOINT ["/entrypoint.sh"]

.github/actions/chocolatey/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Chocolatey publish action'
2+
description: 'Creates package for Chocolatey and pushes it'
3+
inputs:
4+
version:
5+
description: 'Package version'
6+
required: false
7+
chocolateyKey:
8+
description: 'Chocolatey API key'
9+
required: false
10+
publish:
11+
description: 'Whether package should be published'
12+
required: false
13+
default: 'false'
14+
runs:
15+
using: 'docker'
16+
image: 'Dockerfile'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function choco {
6+
mono /opt/chocolatey/choco.exe "$@" --allow-unofficial --nocolor
7+
}
8+
9+
rm -f coder.*.nupkg
10+
11+
mkdir -p tools
12+
cp LICENSE tools/LICENSE.txt
13+
cp VERIFICATION tools/VERIFICATION.txt
14+
sed -i "s/VERSION/${INPUT_VERSION}/g" tools/VERIFICATION.txt
15+
cp ./build/coder_*_windows_amd64.exe tools/
16+
17+
choco pack coder.nuspec --version "${INPUT_VERSION}"
18+
19+
if [[ "$INPUT_PUBLISH" == "true" ]]; then
20+
choco push coder."${INPUT_VERSION}".nupkg --api-key "${INPUT_CHOCOLATEYKEY}" -s https://push.chocolatey.org/ --timeout 180
21+
fi

.github/workflows/release.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ jobs:
104104
go mod download
105105
106106
version="$(./scripts/version.sh)"
107+
echo "CODER_RELEASE_VERSION=$version" >> $GITHUB_ENV
107108
make gen/mark-fresh
108109
make -j \
109110
build/coder_"$version"_linux_{amd64,armv7,arm64}.{tar.gz,apk,deb,rpm} \
@@ -180,3 +181,10 @@ jobs:
180181
./build/*.deb
181182
./build/*.rpm
182183
retention-days: 7
184+
185+
- name: Publish to Chocolatey
186+
uses: ./.github/actions/chocolatey
187+
with:
188+
publish: ${{ ! (github.event.inputs.dry_run || github.event.inputs.snapshot) }}
189+
version: ${{ env.CODER_RELEASE_VERSION }}
190+
chocolateyKey: ${{ secrets.CHOCOLATEY_KEY }}

VERIFICATION

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERIFICATION
2+
Verification is intended to assist the Chocolatey moderators and community
3+
in verifying that this package's contents are trustworthy.
4+
5+
Checksums: https://github.com/coder/coder/releases, in the coder_VERSION_checksums.txt file

coder.nuspec

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
3+
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
4+
<metadata>
5+
<id>coder</id>
6+
<version>0.0.0</version>
7+
<packageSourceUrl>https://github.com/coder/coder</packageSourceUrl>
8+
<owners>coder</owners>
9+
<title>coder</title>
10+
<authors>coder</authors>
11+
<projectUrl>https://coder.com</projectUrl>
12+
<iconUrl>https://github.com/coder/presskit/raw/main/logos/coder%20logo%20black%20square.png</iconUrl>
13+
<copyright>Coder</copyright>
14+
<licenseUrl>https://raw.githubusercontent.com/coder/coder/main/LICENSE</licenseUrl>
15+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
16+
<projectSourceUrl>https://github.com/coder/coder</projectSourceUrl>
17+
<docsUrl>https://coder.com/docs/coder-oss/latest</docsUrl>
18+
<bugTrackerUrl>https://github.com/coder/coder/issues</bugTrackerUrl>
19+
<tags>golang</tags>
20+
<summary>Remote development environments on your infrastructure provisioned with Terraform</summary>
21+
<description>Remote development environments on your infrastructure provisioned with Terraform</description>
22+
</metadata>
23+
<files>
24+
<file src="tools/**" target="tools" />
25+
</files>
26+
</package>

0 commit comments

Comments
 (0)