Skip to content

Commit

Permalink
Merge pull request #7 from glennsarti/add-pkging-process
Browse files Browse the repository at this point in the history
(maint) Add a packaging process
  • Loading branch information
jpogran authored Apr 11, 2018
2 parents 92ab36d + 048f525 commit 5f1b8c1
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ coverage/
log/
.DS_Store
tmp/
output/
137 changes: 137 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Change Log

All notable changes to the "puppet-editor-services" repository will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## Unreleased

## 0.10.0 - 2018-03-29

- ([GH-218](https://github.com/jpogran/puppet-vscode/issues/218)) Validate EPP files
- ([GH-244](https://github.com/jpogran/puppet-vscode/issues/244)) Update puppet-lint to 2.3.5
- ([GH-245](https://github.com/jpogran/puppet-vscode/issues/245)) Update puppet-lint to 2.3.5
- ([GH-216](https://github.com/jpogran/puppet-vscode/issues/216)) Better syntax highlighting
- ([GH-214](https://github.com/jpogran/puppet-vscode/issues/214)) Updated readme for pdk 1.3.X
- ([GH-225](https://github.com/jpogran/puppet-vscode/issues/225)) Readd Local Workspace comand line option
- ([GH-231](https://github.com/jpogran/puppet-vscode/issues/231)) Make Document Validation asynchronous
- ([GH-236](https://github.com/jpogran/puppet-vscode/issues/236)) Remove the preload option
- ([GH-236](https://github.com/jpogran/puppet-vscode/issues/236)) Add experimental file cache option

## 0.9.0 - 2018-02-01

- ([GH-50](https://github.com/jpogran/puppet-vscode/issues/50)) Add document formatter for puppet-lint
- ([GH-204](https://github.com/jpogran/puppet-vscode/issues/204)) Fix debug server for Puppet 4.x

## 0.8.0 - 2017-11-24

- ([GH-180](https://github.com/jpogran/puppet-vscode/issues/180)) Backslashes in File Path do not display in Node Graph
- ([GH-100](https://github.com/jpogran/puppet-vscode/issues/100)) Experimental Puppet-Debugger
- ([PR-194](https://github.com/jpogran/puppet-vscode/pull/194)) Fix logger in PDK New Task
- ([PR-195](https://github.com/jpogran/puppet-vscode/pull/195)) Do not error in validation exception handler
- ([GH-187](https://github.com/jpogran/puppet-vscode/issues/187)) Add stdio mode to language server
- (maint) Fix rubocop violations

## 0.7.2 - 2017-11-01

- ([GH-165](https://github.com/jpogran/puppet-vscode/issues/165)) Broken readme link
- ([GH-88](https://github.com/jpogran/puppet-vscode/issues/88)) Rework Node Graph Preview to use local svg
- ([GH-154](https://github.com/jpogran/puppet-vscode/issues/154)) Use hosted JSON schema files
- ([GH-169](https://github.com/jpogran/puppet-vscode/issues/169)) Fix bug in sytanx highlighting
- ([GH-167](https://github.com/jpogran/puppet-vscode/issues/167)) Add PDK New Task command
- ([GH-156](https://github.com/jpogran/puppet-vscode/issues/156)) Document restarting Puppet extension command
- ([GH-177](https://github.com/jpogran/puppet-vscode/issues/177)) Remove detection of Puppet VERSION file
- ([GH-175](https://github.com/jpogran/puppet-vscode/issues/175)) Fix 'could not find valid version of Puppet'

## 0.7.1 - 2017-09-29

- ([GH-157](https://github.com/jpogran/puppet-vscode/issues/157)) Puppet Resource command hidden

## 0.7.0 - 2017-09-22

- ([GH-115](https://github.com/jpogran/puppet-vscode/issues/115)) Add Puppet Development Kit (PDK) integration
- ([GH-136](https://github.com/jpogran/puppet-vscode/issues/136)) Create a better UI experience while Puppet loads
- ([GH-61](https://github.com/jpogran/puppet-vscode/issues/61)) Create a better experience when language client fails
- ([GH-135](https://github.com/jpogran/puppet-vscode/issues/135)) Fix incorrect logger when a client error occurs
- ([GH-129](https://github.com/jpogran/puppet-vscode/issues/129)) Honor inline puppet lint directives
- ([GH-133](https://github.com/jpogran/puppet-vscode/issues/133)) Fix issue with puppet 5.1.0
- ([GH-122](https://github.com/jpogran/puppet-vscode/issues/122)) Show upgrade message with changelog
- ([GH-120](https://github.com/jpogran/puppet-vscode/issues/120)) Allow custom Puppet agent installation directory
- ([GH-126](https://github.com/jpogran/puppet-vscode/issues/126)) Fix completion provider with Puppet 5.2.0
- ([GH-110](https://github.com/jpogran/puppet-vscode/issues/110)) Add extension analytics
- ([GH-138](https://github.com/jpogran/puppet-vscode/issues/138)) Set extension analytics to prod
- ([GH-109](https://github.com/jpogran/puppet-vscode/issues/109)) Randomize languageserver port
- ([GH-111](https://github.com/jpogran/puppet-vscode/issues/111)) Parse puppet-lint.rc in module directory

## 0.6.0 - 2017-08-08

- Fix packaging error where language server was not included

## 0.5.3 - 2017-08-08

- ([GH-92](https://github.com/jpogran/puppet-vscode/issues/92)) Added context menus for Puppet Resource and Nodegraph preview
- ([GH-98](https://github.com/jpogran/puppet-vscode/issues/98)) Improve language server function and type loading
- ([GH-52](https://github.com/jpogran/puppet-vscode/issues/52)) JSON validation and schema for metadata.json
- ([GH-47](https://github.com/jpogran/puppet-vscode/issues/47)) Fixes pending language server tests
- ([GH-45](https://github.com/jpogran/puppet-vscode/issues/45)) Fix runocop violations for language tcp server
- ([GH-89](https://github.com/jpogran/puppet-vscode/issues/89)) Document support for linux in readme
- ([GH-64](https://github.com/jpogran/puppet-vscode/issues/64)) Additional language server tests
- ([GH-103](https://github.com/jpogran/puppet-vscode/issues/103)) Extension now supports puppet-lint rc files
- ([GH-99](https://github.com/jpogran/puppet-vscode/issues/99)) Improved client README and Gallery page

## 0.4.6 - 2017-06-29

### Changed

- Updated links in README
- Added more information to package manifest
- Minor updates to README

## 0.4.5 - 2017-06-27

### Changed

- Updated badge link location in README

## 0.4.2 - 2017-06-27

### Changed

- Updated badge links to use proper extension id

## 0.4.0 - 2017-06-27

### Added

- A functional Language Server for the Puppet language
- Real time puppet lint
- Auto-complete and Hover support for many puppet language facets
- Auto-complete and Hover support for facts
- 'puppet resource' support
- Preview node graph support
- Tested on older Puppet versions (4.7 LTS series)
- Added testing on Travis and Appveyor

### Fixed

- Completion and Hover provider didn't load puppet modules
- Implemented textDocument/didClose notification
- Fixed completion at file beginning on new lines and on keywords

## 0.0.3 - 2017-05-08

### Added

- Puppet Parser validate linter added

## 0.0.2 - 2017-05-04

### Added

- Puppet Resource and Puppet Module commands.

## 0.0.1 - 2017-04-10

### Added

- Initial release of the puppet extension.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ group :development do
gem "win32-process", "<= 0.7.5", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "win32-security", "<= 0.2.5", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "win32-service", "<= 0.8.8", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]

# Gems for building release tarballs etc.
gem "archive-zip", :require => false
gem "minitar" , :require => false
end

# Evaluate Gemfile.local if it exists
Expand Down
42 changes: 42 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,46 @@ HEREDOC
File.open(File.join(vendor_dir,'README.md'), 'wb') { |file| file.write(readme + "\n") }
end

desc "Create compressed files of the language and debug servers for release"
task :build do
require 'fileutils'
require 'archive/zip'
require 'zlib'
require 'minitar'
require 'digest'

project_dir = File.dirname(__FILE__)
output_dir = File.join(project_dir, 'output')

file_list = ['lib', 'vendor', 'puppet-languageserver', 'puppet-debugserver', 'LICENSE']
# Remove files in the list that do not exist.
file_list.reject! { |filepath| !File.exists?(filepath) }

puts "Cleaning output directory..."
FileUtils.rm_rf Dir.glob("#{output_dir}/*") if Dir.exists?(output_dir)
Dir.mkdir(output_dir) unless Dir.exists?(output_dir)

puts "Fetch editor services version..."
require_relative 'lib/puppet-editor-services/version'
version = PuppetEditorServices.version
puts "Editor services is v#{version}"

puts "Creating zip file..."
zip_archive_file = File.join(output_dir,"puppet_editor_services_#{version}.zip")
Archive::Zip.archive(zip_archive_file, file_list)
puts "Created #{zip_archive_file}"

puts "Creating tar file..."
tar_archive_file = File.join(output_dir,"puppet_editor_services_#{version}.tar.gz")
Minitar.pack(file_list, Zlib::GzipWriter.new(File.open(tar_archive_file, 'wb')))
puts "Created #{tar_archive_file}"

puts "Creating checksums..."
[zip_archive_file, tar_archive_file].each do |filepath|
sha = Digest::SHA256.hexdigest(File.open(filepath, 'rb') { |file| file.read })
File.open(filepath + '.sha256', 'wb') { |file| file.write(sha) }
end
puts "Created checksums"
end

task :default => [:test]
8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ environment:
RUBY_VER: 23-x64
RAKE_TASK: rubocop

# Build release archives
- PUPPET_GEM_VERSION: "~> 4.0"
RUBY_VER: 23-x64
RAKE_TASK: build

matrix:
fast_finish: true

Expand Down Expand Up @@ -70,3 +75,6 @@ build: off

test_script:
- cmd: IF NOT [%RAKE_TASK%] == [] bundle exec rake %RAKE_TASK%

artifacts:
- path: output/*.*
148 changes: 148 additions & 0 deletions tools/upload_release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
param(
[parameter(Mandatory=$true)]
[String]$ReleaseVersion,

[parameter(Mandatory=$true)]
[String]$GitHubUsername,

[parameter(Mandatory=$true)]
[String]$GitHubToken
)

$ErrorActionPreference = 'Stop'

# Adapted from https://www.herebedragons.io/powershell-create-github-release-with-artifact
function Update-GitHubRelease($versionNumber, $preRelease, $releaseNotes, $artifactOutputDirectory, $gitHubUsername, $gitHubRepository, $gitHubApiUsername, $gitHubApiKey)
{
$draft = $false

$auth = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($gitHubApiUsername + ':' + $gitHubApiKey));

# Github uses TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Find existing release
$ReleaseDetails = $null
$releaseParams = @{
Uri = "https://api.github.com/repos/$gitHubUsername/$gitHubRepository/releases/tags/$versionNumber";
Method = 'GET';
Headers = @{
Authorization = $auth;
}
ContentType = 'application/json';
}
try {
$ReleaseDetails = Invoke-RestMethod @releaseParams
}
catch {
# Release is missing, create it
$ReleaseDetails = $null
}

if ($ReleaseDetails -eq $null) {
Write-Host "Creating release $versionNumber"
# Create a release
$releaseData = @{
tag_name = [string]::Format("{0}", $versionNumber);
name = [string]::Format("{0}", $versionNumber);
body = $releaseNotes;
draft = $draft;
prerelease = $preRelease;
}
$releaseParams = @{
ContentType = 'application/json'
Uri = "https://api.github.com/repos/$gitHubUsername/$gitHubRepository/releases";
Method = 'POST';
Headers = @{
Authorization = $auth;
}
Body = (ConvertTo-Json $releaseData -Compress)
}
$ReleaseDetails = Invoke-RestMethod @releaseParams
} else {
Write-Host "Updating release $versionNumber"
# Create a release
$releaseData = @{
tag_name = [string]::Format("{0}", $versionNumber);
name = [string]::Format("{0}", $versionNumber);
body = $releaseNotes;
draft = $draft;
prerelease = $preRelease;
}
$releaseParams = @{
ContentType = 'application/json'
Uri = "https://api.github.com/repos/$gitHubUsername/$gitHubRepository/releases/$($ReleaseDetails.id)";
Method = 'PATCH';
Headers = @{
Authorization = $auth;
}
Body = (ConvertTo-Json $releaseData -Compress)
}
$ReleaseDetails = Invoke-RestMethod @releaseParams
}

# Upload assets
$uploadUri = $ReleaseDetails | Select -ExpandProperty upload_url
$uploadUri = $uploadUri -creplace '\{\?name,label\}'

Get-ChildItem -Path $artifactOutputDirectory | % {
$filename = $_.Name
$filepath = $_.Fullname
Write-Host "Uploading $filename ..."

$uploadParams = @{
Uri = $uploadUri;
Method = 'POST';
Headers = @{
Authorization = $auth;
}
ContentType = 'application/text';
InFile = $filepath
}

if ($filename -match '\.zip$') {
$uploadParams.ContentType = 'application/zip'
}
if ($filename -match '\.gz$') {
$uploadParams.ContentType = 'application/tar+gzip'
}
$uploadParams.Uri += "?name=$filename"

Invoke-RestMethod @uploadParams | Out-Null
}
}

function Get-ReleaseNotes($Version) {
Write-Host "Getting release notes for version $Version ..."

$changelog = Join-Path -Path $PSScriptRoot -ChildPath '..\CHANGELOG.md'

$releaseNotes = $null
$inSection = $false
Get-Content $changelog | % {
$line = $_

if ($inSection) {
if ($line -match "^## ") {
$inSection = $false
} else {
$releaseNotes = $releaseNotes + "`n" + $line
}
} else {
if ($line -match "^## ${version} ") {
$releaseNotes = $line
$inSection = $true
}
}
}
return $releaseNotes
}

Update-GitHubRelease -versionNumber $releaseVersion `
-preRelease $false `
-releaseNotes (Get-ReleaseNotes -Version $releaseVersion) `
-artifactOutputDirectory 'output' `
-gitHubUsername 'lingua-pupuli' `
-gitHubRepository 'puppet-editor-services' `
-gitHubApiUsername $GitHubUsername `
-gitHubApiKey $GitHubToken

0 comments on commit 5f1b8c1

Please sign in to comment.