Skip to content

Commit

Permalink
ci: add action to push chocolatey package
Browse files Browse the repository at this point in the history
  • Loading branch information
panekj committed Oct 25, 2022
1 parent df89e2c commit 9cd2f31
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/actions/chocolatey/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM alpine:latest

ARG CHOCOVERSION=1.1.0

RUN apk add --no-cache bash ca-certificates git \
&& apk --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing add mono mono-dev \
&& cert-sync /etc/ssl/certs/ca-certificates.crt \
&& wget "https://github.com/chocolatey/choco/archive/${CHOCOVERSION}.tar.gz" -O- | tar -xzf - \
&& cd choco-"${CHOCOVERSION}" \
&& chmod +x build.sh zip.sh \
&& ./build.sh -v \
&& mv ./code_drop/chocolatey/console /opt/chocolatey \
&& mkdir -p /opt/chocolatey/lib \
&& rm -rf /choco-"${CHOCOVERSION}" \
&& apk del mono-dev \
&& rm -rf /var/cache/apk/*

ENV ChocolateyInstall=/opt/chocolatey
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
16 changes: 16 additions & 0 deletions .github/actions/chocolatey/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Chocolatey publish action'
description: 'Creates package for Chocolatey and pushes it'
inputs:
version:
description: 'Package version'
required: false
chocolateyKey:
description: 'Chocolatey API key'
required: false
publish:
description: 'Whether package should be published'
required: false
default: 'false'
runs:
using: 'docker'
image: 'Dockerfile'
21 changes: 21 additions & 0 deletions .github/actions/chocolatey/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

function choco {
mono /opt/chocolatey/choco.exe "$@" --allow-unofficial --nocolor
}

rm -f coder.*.nupkg

mkdir -p tools
cp LICENSE tools/LICENSE.txt
cp VERIFICATION tools/VERIFICATION.txt
sed -i "s/VERSION/${INPUT_VERSION}/g" tools/VERIFICATION.txt
cp ./build/coder_*_windows_amd64.exe tools/

choco pack coder.nuspec --version "${INPUT_VERSION}"

if [[ "$INPUT_PUBLISH" == "true" ]]; then
choco push coder."${INPUT_VERSION}".nupkg --api-key "${INPUT_CHOCOLATEYKEY}" -s https://push.chocolatey.org/ --timeout 180
fi
8 changes: 8 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ jobs:
go mod download
version="$(./scripts/version.sh)"
echo "CODER_RELEASE_VERSION=$version" >> $GITHUB_ENV
make gen/mark-fresh
make -j \
build/coder_"$version"_linux_{amd64,armv7,arm64}.{tar.gz,apk,deb,rpm} \
Expand Down Expand Up @@ -180,3 +181,10 @@ jobs:
./build/*.deb
./build/*.rpm
retention-days: 7

- name: Publish to Chocolatey
uses: ./.github/actions/chocolatey
with:
publish: ${{ ! (github.event.inputs.dry_run || github.event.inputs.snapshot) }}
version: ${{ env.CODER_RELEASE_VERSION }}
chocolateyKey: ${{ secrets.CHOCOLATEY_KEY }}
5 changes: 5 additions & 0 deletions VERIFICATION
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

Checksums: https://github.com/coder/coder/releases, in the coder_VERSION_checksums.txt file
26 changes: 26 additions & 0 deletions coder.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>coder</id>
<version>0.0.0</version>
<packageSourceUrl>https://github.com/coder/coder</packageSourceUrl>
<owners>coder</owners>
<title>coder</title>
<authors>coder</authors>
<projectUrl>https://coder.com</projectUrl>
<iconUrl>https://github.com/coder/presskit/raw/main/logos/coder%20logo%20black%20square.png</iconUrl>
<copyright>Coder</copyright>
<licenseUrl>https://raw.githubusercontent.com/coder/coder/main/LICENSE</licenseUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/coder/coder</projectSourceUrl>
<docsUrl>https://coder.com/docs/coder-oss/latest</docsUrl>
<bugTrackerUrl>https://github.com/coder/coder/issues</bugTrackerUrl>
<tags>golang</tags>
<summary>Remote development environments on your infrastructure provisioned with Terraform</summary>
<description>Remote development environments on your infrastructure provisioned with Terraform</description>
</metadata>
<files>
<file src="tools/**" target="tools" />
</files>
</package>

0 comments on commit 9cd2f31

Please sign in to comment.