Skip to content

Commit

Permalink
Merge pull request #31 from carolynvs/gh-releases
Browse files Browse the repository at this point in the history
Publish to GH
  • Loading branch information
carolynvs authored Apr 8, 2021
2 parents 4f493b7 + 70a4d40 commit 5103eb5
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bin
*-packr.go
/docker
/docker.exe
/build/git_askpass.sh
17 changes: 1 addition & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,7 @@ test-integration: xbuild
$(GO) test -tags=integration ./tests/...

publish: bin/porter$(FILE_EXT)
# The following demonstrates how to publish a mixin. As an example, we show how to publish to azure.
# The porter mixins feed generate command is used to build an ATOM feed for sharing mixins once published

# AZURE_STORAGE_CONNECTION_STRING will be used for auth in the following commands
if [[ "$(PERMALINK)" == "latest" ]]; then \
az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(VERSION) -s $(BINDIR)/$(VERSION); \
az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(PERMALINK) -s $(BINDIR)/$(VERSION); \
else \
mv $(BINDIR)/$(VERSION) $(BINDIR)/$(PERMALINK); \
az storage blob upload-batch -d porter/mixins/$(MIXIN)/$(PERMALINK) -s $(BINDIR)/$(PERMALINK); \
fi

# Generate the mixin feed
az storage blob download -c porter -n atom.xml -f bin/atom.xml
bin/porter mixins feed generate -d bin/mixins -f bin/atom.xml -t build/atom-template.xml
az storage blob upload -c porter -n atom.xml -f bin/atom.xml
go run mage.go Publish $(MIXIN) $(VERSION) $(PERMALINK)

bin/porter$(FILE_EXT):
curl -fsSLo bin/porter$(FILE_EXT) https://cdn.porter.sh/canary/porter-$(CLIENT_PLATFORM)-$(CLIENT_ARCH)$(FILE_EXT)
Expand Down
6 changes: 4 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trigger:
branches:
include:
- refs/heads/main
- refs/tags/*
- refs/tags/v*

pool:
vmImage: 'Ubuntu 16.04'
Expand Down Expand Up @@ -37,6 +37,8 @@ steps:
displayName: 'Integration Test'

- script: |
AZURE_STORAGE_CONNECTION_STRING=$(AZURE_STORAGE_CONNECTION_STRING) make publish
make publish
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
displayName: 'Publish'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module get.porter.sh/mixin/docker
go 1.13

require (
get.porter.sh/porter v0.27.2-0.20200720191056-a355e3031887
get.porter.sh/porter v0.37.2
github.com/ghodss/yaml v1.0.0
github.com/gobuffalo/packr/v2 v2.8.0
github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.6
github.com/stretchr/testify v1.5.1
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
github.com/xeipuuv/gojsonschema v1.2.0
gopkg.in/yaml.v2 v2.2.4
)
Expand Down
122 changes: 95 additions & 27 deletions go.sum

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions mage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// +build ignore

package main

import (
"os"

"github.com/magefile/mage/mage"
)

// This file allows someone to run mage commands without mage installed
// by running `go run mage.go TARGET`.
// See https://magefile.org/zeroinstall/
func main() { os.Exit(mage.Main()) }
17 changes: 17 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// +build mage

package main

import (
// mage:import
"get.porter.sh/porter/mage/releases"
)

// We are migrating to mage, but for now keep using make as the main build script interface.

// Publish the cross-compiled binaries.
func Publish(mixin string, version string, permalink string) {
releases.PrepareMixinForPublish(mixin, version, permalink)
releases.PublishMixin(mixin, version, permalink)
releases.PublishMixinFeed(mixin, version)
}
5 changes: 2 additions & 3 deletions pkg/docker/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package docker
import (
"bytes"
"io/ioutil"
"os"
"path"
"testing"

Expand Down Expand Up @@ -38,12 +37,12 @@ func TestMixin_Execute(t *testing.T) {
"docker build -f myfile -t practice /Users/myuser/Documents"},
}

defer os.Unsetenv(test.ExpectedCommandEnv)
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
m := NewTestMixin(t)

os.Setenv(test.ExpectedCommandEnv, tc.wantCommand)
m.Setenv(test.ExpectedCommandEnv, tc.wantCommand)
mixinInputB, err := ioutil.ReadFile(tc.file)
require.NoError(t, err)

Expand Down

0 comments on commit 5103eb5

Please sign in to comment.