Skip to content

Commit

Permalink
chore: publishing adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Oct 20, 2020
1 parent 919283f commit 4272bc2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/publish-latest.yml
Expand Up @@ -10,8 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build daemon
run: make daemon-release RELEASE=latest

run: RELEASE=latest bash .scripts/build_release_daemon.sh
- name: Publish to GitHub Container Registry
run: |
echo ${{ secrets.GH_PACKAGES_TOKEN }} | docker login ghcr.io --username $GITHUB_ACTOR --password-stdin
Expand Down
33 changes: 18 additions & 15 deletions .github/workflows/publish-release.yml
Expand Up @@ -9,39 +9,42 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with: { go-version: '1.15' }
- name: Build release
run: |
docker login -u ${{ secrets.docker_user }} -p ${{ secrets.docker_key }}
RELEASE=$(git describe --tags) bash .scripts/build_release.sh
# Inertia daemon
- name: 'daemon: publish to Docker Hub'
RELEASE=$(git describe --tags) bash .scripts/build_release_daemon.sh
- name: Publish to Docker Hub
run: |
docker login -u ${{ secrets.docker_user }} -p ${{ secrets.docker_key }}
# Publish as legacy name
docker tag ubclaunchpad/inertiad:$(git describe --tags) ubclaunchpad/inertia:$(git describe --tags)
docker push ubclaunchpad/inertia:$(git describe --tags)
- name: 'daemon: publish to GitHub Container Registry'
- name: Publish to GitHub Container Registry
run: |
echo ${{ secrets.GH_PACKAGES_TOKEN }} | docker login ghcr.io --username $GITHUB_ACTOR --password-stdin
docker tag ubclaunchpad/inertiad:$(git describe --tags) ghcr.io/ubclaunchpad/inertiad:$(git describe --tags)
docker push ghcr.io/ubclaunchpad/inertiad:$(git describe --tags)
# Inertia CLI
- name: 'cli: publish to GitHub'
cli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with: { go-version: '1.15' }
- name: Build release
run: |
RELEASE=$(git describe --tags) bash .scripts/build_release_cli.sh
- name: Publish to GitHub
uses: softprops/action-gh-release@v1
with:
files: inertia.v*
files: dist/inertia.v*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'cli: publish to Homebrew and Scoop'
- name: Publish to Homebrew and Scoop
if: github.event.release.prerelease != true
env:
GIT_CREDENTIALS: 'ubclaunchpad-bot:${{ secrets.LP_GH_PUBLIC_REPO_TOKEN }}'
run: |
git config --global user.email 'team+bot@ubclaunchpad.com'
git config --global user.name 'ubclaunchpad-bot'
git config --global user.password ${{ secrets.LP_GH_PUBLIC_REPO_TOKEN }}
go run ./contrib/inertia-publish $(git describe --tags) \
go run ./contrib/inertia-publish $(git describe --tags) --dryrun=false \
homebrew scoop \
--dryrun=false
5 changes: 1 addition & 4 deletions .scripts/build_release.sh → .scripts/build_release_cli.sh
Expand Up @@ -2,10 +2,7 @@

# Specify platforms and release version
PLATFORMS="linux/amd64 linux/386 darwin/amd64 windows/amd64 windows/386"
echo "Building release $RELEASE"

# Build, tag and push Inertia Docker image
make daemon-release RELEASE="$RELEASE"
echo "Building CLI release $RELEASE"

# Build Inertia Go binaries for specified platforms
OUTDIR=${OUTDIR:-"dist"}
Expand Down
7 changes: 7 additions & 0 deletions .scripts/build_release_daemon.sh
@@ -0,0 +1,7 @@
#! /bin/bash

# Specify platforms and release version
echo "Building daemon release $RELEASE"

# Build, tag and push Inertia Docker image
make daemon-release RELEASE="$RELEASE"
15 changes: 11 additions & 4 deletions contrib/inertia-publish/main.go
Expand Up @@ -74,6 +74,16 @@ func newCommand(dir, name string, args ...string) *exec.Cmd {
return cmd
}

func getCloneURL(repository string) string {
// GIT_CREDENTIALS should be $USER:$TOKEN
if creds := os.Getenv("GIT_CREDENTIALS"); creds != "" {
// "Personal access tokens can only be used for HTTPS Git operations.""
// https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token#using-a-token-on-the-command-line
return fmt.Sprintf("https://%s@github.com/%s.git", creds, repository)
}
return fmt.Sprintf("https://github.com/%s.git", repository)
}

type channelConfig struct {
Repository string
Template string
Expand All @@ -84,10 +94,7 @@ func (c *channelConfig) Publish(version, outdir string, renderedTemplate []byte,
// load repository
repoPath := filepath.Join(outdir, c.Repository)
os.RemoveAll(repoPath)
clone := newCommand(outdir, "git", "clone",
// "Personal access tokens can only be used for HTTPS Git operations.""
// https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token#using-a-token-on-the-command-line
fmt.Sprintf("https://github.com/%s.git", c.Repository),
clone := newCommand(outdir, "git", "clone", getCloneURL(c.Repository),
// clone into subdirectory
c.Repository)
if err := clone.Run(); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions contrib/inertia-publish/templates/doc.go
@@ -0,0 +1,2 @@
// Package templates provides template scripts for distribution channels
package templates

0 comments on commit 4272bc2

Please sign in to comment.