Skip to content

Commit

Permalink
Merge pull request #48 from duplocloud/releaser
Browse files Browse the repository at this point in the history
Releaser
  • Loading branch information
kferrone authored Mar 8, 2024
2 parents 4a15b0e + 9b62b97 commit c31b4a9
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 111 deletions.
84 changes: 3 additions & 81 deletions .github/workflows/installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@ name: Publish Release

on:
workflow_dispatch:
inputs:
prerelease:
description: Push to github releases?
required: false
default: true
type: boolean
workflow_call:
inputs:
prerelease:
description: Push the image to the registry
required: false
default: true
type: boolean

jobs:
installer:
Expand Down Expand Up @@ -54,78 +42,12 @@ jobs:

- name: Pyinstaller
id: installer
run: pyinstaller cli.spec
run: pyinstaller installer.spec

- name: View Files
run: ls dist/cli
run: ls dist/duplocloud

- uses: actions/upload-artifact@v4
with:
name: ${{ steps.set_tag.outputs.NAME }}
path: dist/cli/duploctl*

releaser:
name: Release
runs-on: ubuntu-latest
needs: installer
outputs:
name: ${{ steps.set_tag.outputs.NAME }}
steps:

- name: Dist Dir
id: dist_dir
run: mkdir -p dist artifacts

- name: Get Tag Name
id: set_tag
run: |
GIT_TAG=${GITHUB_REF#refs/*/}
VERSION=$(echo $GIT_TAG | cut -d'v' -f2)
NAME="duploctl-${GIT_TAG}"
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "NAME=${NAME}" >> $GITHUB_OUTPUT
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ steps.set_tag.outputs.NAME }}-*
path: artifacts
merge-multiple: false

- name: Prep Release
shell: bash
run: |
for d in artifacts/*; do
name=$(basename $d)
file="$(find "$d" -type f -name "duploctl*")"
if [[ $file == *.exe ]]; then
name="${name}.exe"
fi
dest="dist/${name}"
mv $file $dest
done
ls dist
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/*
body: |
duploctl ${{ steps.set_tag.outputs.GIT_TAG }} is out!.
PyPi:
[duplocloud-client](https://pypi.org/project/duplocloud-client/${{ steps.set_tag.outputs.VERSION }}/)
```sh
pip install duplocloud-client==${{ steps.set_tag.outputs.VERSION }}
```
Dockerhub:
[duplocloud/duploctl:${{ steps.set_tag.outputs.GIT_TAG }}](https://hub.docker.com/r/duplocloud/duploctl)
```sh
docker pull duplocloud/duploctl:${{ steps.set_tag.outputs.GIT_TAG }}
```
prerelease: ${{ github.event.inputs.prerelease }}
path: dist/duplocloud
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish Version
on:
push:
tags:
- '*'
- 'v*'

jobs:

Expand All @@ -22,8 +22,8 @@ jobs:
uses: ./.github/workflows/installer.yml
secrets: inherit

notify:
name: Slack notify
uses: ./.github/workflows/slack-notify.yml
release:
name: Release
uses: ./.github/workflows/release.yml
secrets: inherit
needs: [package, installer, image]
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Releaser

on:
workflow_call:

jobs:
releaser:
runs-on: ubuntu-latest
steps:

- name: Dist Dir
id: dist_dir
run: mkdir -p dist artifacts

- name: Get Tag Name
id: set_tag
run: |
GIT_TAG=${GITHUB_REF#refs/*/}
VERSION=$(echo $GIT_TAG | cut -d'v' -f2)
NAME="duploctl-${GIT_TAG}"
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "NAME=${NAME}" >> $GITHUB_OUTPUT
- name: Build Release Message
id: message
env:
GIT_TAG: ${{ steps.set_tag.outputs.GIT_TAG }}
VERSION: ${{ steps.set_tag.outputs.VERSION }}
run: |
MESSAGE="$(cat <<EOF
duploctl ${GIT_TAG} is out!.
PyPi:
[duplocloud-client](https://pypi.org/project/duplocloud-client/${VERSION}/)
```sh
pip install duplocloud-client==${VERSION}
```
Dockerhub:
[duplocloud/duploctl:${GIT_TAG}](https://hub.docker.com/r/duplocloud/duploctl)
```sh
docker pull duplocloud/duploctl:${GIT_TAG}
```
EOF
)"
echo "MESSAGE=${MESSAGE}" >> $GITHUB_OUTPUT
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ steps.set_tag.outputs.NAME }}-*
path: artifacts
merge-multiple: false

- name: Compress Artifacts
shell: bash
run: |
for d in artifacts/*; do
name=$(basename $d)
dest="dist/${name}.tar.gz"
tar -czvf "$dest" -C $d .
done
- name: Create Release
id: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/*
body: ${{ steps.message.outputs.MESSAGE }}
prerelease: ${{ github.event.inputs.prerelease }}

- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
slack-message: |
duploctl ${{ steps.set_tag.outputs.GIT_TAG }} is out!
${{ steps.release.outputs.url }}
- name: Job Summary
env:
MESSAGE: ${{ steps.message.outputs.MESSAGE }}
run: echo "$MESSAGE" >> $GITHUB_STEP_SUMMARY

24 changes: 0 additions & 24 deletions .github/workflows/slack-notify.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ python -m build

Create a single binary build for the cli.
```sh
pyinstaller cli.spec
pyinstaller installer.spec
```

## Semver with Setuptools SCM command
Expand Down
2 changes: 1 addition & 1 deletion cli.spec → installer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ coll = COLLECT(
strip=False,
upx=True,
upx_exclude=[],
name='cli',
name='duplocloud',
)

0 comments on commit c31b4a9

Please sign in to comment.