Skip to content

Commit

Permalink
Added Chocolatey release process
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Dines committed Aug 13, 2018
1 parent d8bc27d commit 01b9943
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 11 deletions.
40 changes: 34 additions & 6 deletions .circleci/config.yml
Expand Up @@ -42,9 +42,10 @@ jobs:
path: /tmp/test-results

- persist_to_workspace:
root: bin
root: '.'
paths:
- '*'
- bin
- vendor

release-github:
<<: *defaults
Expand All @@ -55,10 +56,8 @@ jobs:
steps:
- checkout

- run: *install_dep

- attach_workspace:
at: bin
at: '.'

- run: &validate_tag_version
name: Validate Tag Version
Expand Down Expand Up @@ -125,7 +124,7 @@ jobs:
- checkout

- attach_workspace:
at: bin
at: '.'

- run: *validate_tag_version

Expand Down Expand Up @@ -163,6 +162,26 @@ jobs:
name: Release to Homebrew Tap
command: make brew-release FORGE_VERSION="$CIRCLE_TAG"

release-chocolatey:
docker:
- image: linuturk/mono-choco:latest

steps:
- checkout

- attach_workspace:
at: '.'

- run:
name: Install make
command: |
apt-get update
apt-get install make
- run:
name: Release to Chocolatey
command: make choco-release FORGE_VERSION="$CIRCLE_TAG" LICENSE_COMMIT="$CIRCLE_SHA1"

workflows:
version: 2
build-n-release:
Expand Down Expand Up @@ -196,6 +215,15 @@ workflows:
only: /^v\d+(?:\.\d+){2}$/
branches:
ignore: /.*/
- release-chocolatey:
context: chocolatey
requires:
- release-github
filters:
tags:
only: /^v\d+(?:\.\d+){2}$/
branches:
ignore: /.*/
nightly:
triggers:
- schedule:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,9 @@ bin
vendor
coverage.out
homebrew
chocolatey/forge/forge.nuspec
chocolatey/forge/tools/LICENSE.txt
chocolatey/forge/tools/VERIFICATION.txt
chocolatey/**/*.exe
chocolatey/**/*.nupkg
chocolatey/**/*.zip
37 changes: 32 additions & 5 deletions Makefile
@@ -1,4 +1,4 @@
.PHONY: build test clean deps lint gofmt govet godiff coverage
.PHONY: build test clean deps lint gofmt govet godiff coverage choco-package choco-release brew-release

BINARY = bin/forge

Expand Down Expand Up @@ -46,15 +46,42 @@ godiff:

BREW_FORMULA := homebrew/forge.rb
brew-release:
ifndef FORGE_VERSION
$(eval FORGE_VERSION := $(shell '$(BINARY)' --version | awk '{ print $$NF }'))
endif
$(eval FORGE_VERSION ?= $(shell '$(BINARY)' --version | awk '{ print $$NF }'))
$(eval ARCHIVE_URL := https://github.com/nathandines/forge/archive/$(FORGE_VERSION).tar.gz)
$(eval ARCHIVE_SHA256 := $(shell curl -o - -Ls '$(ARCHIVE_URL)' | shasum -a 256 | awk '{ print $$1 }'))
[ -d homebrew ] || git clone 'git@github.com:nathandines/homebrew-tap.git' 'homebrew'
sed 's;{{ archive_url }};$(ARCHIVE_URL);g;s;{{ archive_sha256 }};$(ARCHIVE_SHA256);g' \
sed -e 's;{{ archive_url }};$(ARCHIVE_URL);g' \
-e 's;{{ archive_sha256 }};$(ARCHIVE_SHA256);g' \
homebrew_formula.rb.template > '$(BREW_FORMULA)'
brew audit --strict '$(BREW_FORMULA)'
cd 'homebrew' && \
git commit -m 'forge: $(FORGE_VERSION)' -- forge.rb && \
git push origin master

CHOCO ?= choco
CHOCO_FORGE_PATH := $(PWD)/chocolatey/forge
CHOCO_NUSPEC := $(CHOCO_FORGE_PATH)/forge.nuspec
LICENSE_COMMIT ?= master
choco-package:
$(eval FORGE_VERSION ?= $(shell '$(BINARY)' --version | awk '{ print $$NF }'))
$(eval URL_x64 := https://github.com/nathandines/forge/releases/download/$(FORGE_VERSION)/forge_$(FORGE_VERSION)_windows_amd64.exe)
$(eval URL_386 := https://github.com/nathandines/forge/releases/download/$(FORGE_VERSION)/forge_$(FORGE_VERSION)_windows_386.exe)
mkdir -p '$(CHOCO_FORGE_PATH)/tools'
rm -f '$(CHOCO_FORGE_PATH)/tools/forge_'*.zip
cp LICENSE '$(CHOCO_FORGE_PATH)/tools/LICENSE.txt'
sed 's/{{ package_version }}/$(FORGE_VERSION:v%=%)/g' 'chocolatey/forge/chocolatey_package.nuspec.template' > '$(CHOCO_NUSPEC)'
curl -Lo 'forge64.exe' '$(URL_x64)'
curl -Lo 'forge32.exe' '$(URL_386)'
zip -v '$(CHOCO_FORGE_PATH)/tools/forge_$(FORGE_VERSION).zip' forge64.exe forge32.exe
sed -e 's;{{ url_x64 }};$(URL_x64);g' \
-e "s;{{ sha256_x64 }};$$(shasum -a 256 forge64.exe | awk '{ print $$1 }');g" \
-e 's;{{ url_386 }};$(URL_386);g' \
-e "s;{{ sha256_386 }};$$(shasum -a 256 forge32.exe | awk '{ print $$1 }');g" \
-e 's;{{ license_commit }};$(LICENSE_COMMIT);g' \
'chocolatey/forge/VERIFICATION.txt.template' > 'chocolatey/forge/tools/VERIFICATION.txt'
rm -f forge32.exe forge64.exe '$(CHOCO_FORGE_PATH)/forge.$(FORGE_VERSION:v%=%).nupkg'
cd '$(CHOCO_FORGE_PATH)' && $(CHOCO) pack '$(CHOCO_NUSPEC)'

choco-release: choco-package
$(eval FORGE_VERSION ?= $(shell '$(BINARY)' --version | awk '{ print $$NF }'))
$(CHOCO) push --api-key='$(CHOCO_API_KEY)' '$(CHOCO_FORGE_PATH)/forge.$(FORGE_VERSION:v%=%).nupkg'
23 changes: 23 additions & 0 deletions chocolatey/forge/VERIFICATION.txt.template
@@ -0,0 +1,23 @@
VERIFICATION

Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

Package can be verified like this:

1. Go to

x32: {{ url_386 }}
x64: {{ url_x64 }}

to download the binary.

2. You can use one of the following methods to obtain the SHA256 checksum:
- Use powershell function 'Get-FileHash'
- Use Chocolatey utility 'checksum.exe'

checksum32: {{ sha256_386 }}
checksum64: {{ sha256_x64 }}

File 'license.txt' is obtained from:
https://github.com/nathandines/forge/blob/{{ license_commit }}/LICENSE
27 changes: 27 additions & 0 deletions chocolatey/forge/chocolatey_package.nuspec.template
@@ -0,0 +1,27 @@
<?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>forge</id>
<version>{{ package_version }}</version>
<packageSourceUrl>https://github.com/nathandines/forge</packageSourceUrl>
<owners>Nathan Dines</owners>

<title>forge</title>
<authors>Nathan Dines</authors>
<projectUrl>https://github.com/nathandines/forge</projectUrl>
<copyright>2018 Nathan Dines</copyright>
<licenseUrl>https://github.com/nathandines/forge/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/nathandines/forge</projectSourceUrl>
<bugTrackerUrl>https://github.com/nathandines/forge/issues</bugTrackerUrl>
<tags>forge cloudformation aws golang continuous-delivery</tags>
<summary>Continuous Delivery friendly CloudFormation deployment tool</summary>
<description>
Forge is a simple tool which makes deploying CloudFormation stacks a bit easier in continuous delivery environments. In contrast to awscli, Forge provides a mechanism to create, update and delete CloudFormation stacks synchronously, while also providing output on the stack events, and an exit code reflecting the final state of the stack deployment.
</description>
</metadata>
<files>
<file src="tools/**" target="tools" />
</files>
</package>
24 changes: 24 additions & 0 deletions chocolatey/forge/tools/chocolateyInstall.ps1
@@ -0,0 +1,24 @@
$ErrorActionPreference = 'Stop'

$fileName = "forge_v${Env:ChocolateyPackageVersion}.zip"
$toolsPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$zip_path = "$toolsPath\$fileName"
Remove-Item $toolsPath\* -Recurse -Force -Exclude $fileName

$packageArgs = @{
PackageName = 'forge'
FileFullPath = $zip_path
Destination = $toolsPath
}
Get-ChocolateyUnzip @packageArgs
Remove-Item $zip_path -ea 0

if ((Get-OSArchitectureWidth 64) -or $Env:ChocolateyForceX86) {
Write-Verbose "Removing x32 version"
Remove-Item "$toolsPath/forge32.exe" -ea 0
Move-Item "$toolsPath/forge64.exe" "$toolsPath/forge.exe" -Force
} else {
Write-Verbose "Removing x64 version"
Remove-Item "$toolsPath/forge64.exe" -ea 0
Move-Item "$toolsPath/forge32.exe" "$toolsPath/forge.exe" -Force
}

0 comments on commit 01b9943

Please sign in to comment.