add goreleaser
authorSenorGrande <clooneyjh@gmail.com>
Sun, 4 Oct 2020 03:11:14 +0000 (16:11 +1300)
committerSenorGrande <clooneyjh@gmail.com>
Sun, 4 Oct 2020 03:11:14 +0000 (16:11 +1300)
goreleaser/README.md [new file with mode: 0644]
goreleaser/install.ps1 [new file with mode: 0644]
goreleaser/install.sh [new file with mode: 0644]
goreleaser/releases.js [new file with mode: 0644]
package-lock.json

diff --git a/goreleaser/README.md b/goreleaser/README.md
new file mode 100644 (file)
index 0000000..afeb071
--- /dev/null
@@ -0,0 +1,31 @@
+---
+title: goreleaser
+homepage: https://goreleaser.com
+tagline: |
+  goreleaser: Deliver Go binaries as fast and easily as possible
+---
+
+### Updating `goreleaser`
+
+`webi goreleaser@stable`
+
+Use the `@beta` tag for pre-releases.
+
+## Cheat Sheet
+
+> `goreleaser` doesn't exist and this text should have been replaced. It doesn't do
+> anything, but what it does is useful because it is; everybody knows it.
+
+To run goreleaser:
+
+```bash
+goreleaser
+```
+
+### Add Baz Highlighting
+
+To run goreleaser with both bar and baz highlighting turned on:
+
+```bash
+goreleaser --bar=baz
+```
diff --git a/goreleaser/install.ps1 b/goreleaser/install.ps1
new file mode 100644 (file)
index 0000000..08f4716
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env pwsh
+
+######################
+# Install goreleaser #
+######################
+
+# Every package should define these variables
+$pkg_cmd_name = "goreleaser"
+
+$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\goreleaser.exe"
+$pkg_dst = "$pkg_dst_cmd"
+
+$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\goreleaser-v$Env:WEBI_VERSION\bin\goreleaser.exe"
+$pkg_src_bin = "$Env:USERPROFILE\.local\opt\goreleaser-v$Env:WEBI_VERSION\bin"
+$pkg_src_dir = "$Env:USERPROFILE\.local\opt\goreleaser-v$Env:WEBI_VERSION"
+$pkg_src = "$pkg_src_cmd"
+
+$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
+
+# Fetch archive
+IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
+{
+    # TODO: arch detection
+    echo "Downloading goreleaser from $Env:WEBI_PKG_URL to $pkg_download"
+    & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
+    & move "$pkg_download.part" "$pkg_download"
+}
+
+IF (!(Test-Path -Path "$pkg_src_cmd"))
+{
+    echo "Installing goreleaser"
+
+    # TODO: create package-specific temp directory
+    # Enter tmp
+    pushd .local\tmp
+
+        # Remove any leftover tmp cruft 
+        Remove-Item -Path ".\goreleaser-v*" -Recurse -ErrorAction Ignore
+        Remove-Item -Path ".\goreleaser.exe" -Recurse -ErrorAction Ignore
+
+        # Unpack archive file into this temporary directory
+        # Windows BSD-tar handles zip. Imagine that.
+        echo "Unpacking $pkg_download"
+        & tar xf "$pkg_download"
+
+        # Settle unpacked archive into place
+        echo "Install Location: $pkg_src_cmd"
+        New-Item "$pkg_src_bin" -ItemType Directory
+        Move-Item -Path ".\goreleaser.exe" -Destination "$pkg_src_bin"
+
+    # Exit tmp
+    popd
+}
+
+echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
+Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
+Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
diff --git a/goreleaser/install.sh b/goreleaser/install.sh
new file mode 100644 (file)
index 0000000..b11248e
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    ######################
+    # Install goreleaser #
+    ######################
+
+    # Every package should define these 6 variables
+    pkg_cmd_name="goreleaser"
+
+    pkg_dst_cmd="$HOME/.local/bin/goreleaser"
+    pkg_dst="$pkg_dst_cmd"
+
+    pkg_src_cmd="$HOME/.local/opt/goreleaser-v$WEBI_VERSION/bin/goreleaser"
+    pkg_src_dir="$HOME/.local/opt/goreleaser-v$WEBI_VERSION"
+    pkg_src="$pkg_src_cmd"
+
+    # pkg_install must be defined by every package
+    pkg_install() {
+        # ~/.local/opt/goreleaser-v0.99.9/bin
+        mkdir -p "$(dirname $pkg_src_cmd)"
+
+        # mv ./goreleaser-*/goreleaser ~/.local/opt/goreleaser-v0.99.9/bin/goreleaser
+        mv ./goreleaser "$pkg_src_cmd"
+    }
+
+    # pkg_get_current_version is recommended, but (soon) not required
+    pkg_get_current_version() {
+        # 'goreleaser --version' has output in this format:
+        #       goreleaser 0.99.9 (rev abcdef0123)
+        # This trims it down to just the version number:
+        #       0.99.9
+        echo $(goreleaser --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2)
+    }
+
+}
diff --git a/goreleaser/releases.js b/goreleaser/releases.js
new file mode 100644 (file)
index 0000000..77dd21b
--- /dev/null
@@ -0,0 +1,28 @@
+'use strict';
+
+var github = require('../_common/github.js');
+var owner = 'goreleaser';
+var repo = 'goreleaser';
+
+/******************************************************************************/
+/** Note: Delete this Comment!                                               **/
+/**                                                                          **/
+/** Need a an example that filters out miscellaneous release files?          **/
+/**   See `deno`, `gitea`, or `caddy`                                        **/
+/**                                                                          **/
+/******************************************************************************/
+
+module.exports = function (request) {
+  return github(request, owner, repo).then(function (all) {
+    return all;
+  });
+};
+
+if (module === require.main) {
+  module.exports(require('@root/request')).then(function (all) {
+    all = require('../_webi/normalize.js')(all);
+    // just select the first 5 for demonstration
+    all.releases = all.releases.slice(0, 5);
+    console.info(JSON.stringify(all, null, 2));
+  });
+}
index 304b4e4568c31586723d186c3b7d2d0803e00cf1..b2abb458a8facf57f6a7e017cfb453753b9e2287 100644 (file)
@@ -1,6 +1,6 @@
 {
-  "name": "@webinstall/packages",
-  "version": "0.1.0",
+  "name": "@webinstall/webi-installers",
+  "version": "0.2.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {