Skip to content

Commit 3a07fe8

Browse files
authored
Merge pull request #134 from dokku/automate-releases
feat: add ability to create releases from a github workflow
2 parents 1a4093d + 5fe6016 commit 3a07fe8

File tree

10 files changed

+210
-48
lines changed

10 files changed

+210
-48
lines changed

.github/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.3.1

.github/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
ruby file: ".ruby-version"
4+
5+
gem "fpm"
6+
gem "package_cloud"

.github/Gemfile.lock

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
arr-pm (0.0.12)
5+
backports (3.25.0)
6+
cabin (0.9.0)
7+
clamp (1.0.1)
8+
domain_name (0.6.20240107)
9+
dotenv (3.1.2)
10+
fpm (1.15.1)
11+
arr-pm (~> 0.0.11)
12+
backports (>= 2.6.2)
13+
cabin (>= 0.6.0)
14+
clamp (~> 1.0.0)
15+
pleaserun (~> 0.0.29)
16+
rexml
17+
stud
18+
highline (2.0.3)
19+
http-accept (1.7.0)
20+
http-cookie (1.0.5)
21+
domain_name (~> 0.5)
22+
insist (1.0.0)
23+
json_pure (2.3.1)
24+
mime-types (3.5.2)
25+
mime-types-data (~> 3.2015)
26+
mime-types-data (3.2024.0507)
27+
mustache (0.99.8)
28+
netrc (0.11.0)
29+
package_cloud (0.3.14)
30+
highline (~> 2.0.0)
31+
json_pure (~> 2.3.0)
32+
rainbow (= 2.2.2)
33+
rest-client (~> 2.0)
34+
thor (~> 1.2)
35+
pleaserun (0.0.32)
36+
cabin (> 0)
37+
clamp
38+
dotenv
39+
insist
40+
mustache (= 0.99.8)
41+
stud
42+
rainbow (2.2.2)
43+
rake
44+
rake (13.2.1)
45+
rest-client (2.1.0)
46+
http-accept (>= 1.7.0, < 2.0)
47+
http-cookie (>= 1.0.2, < 2.0)
48+
mime-types (>= 1.16, < 4.0)
49+
netrc (~> 0.8)
50+
rexml (3.2.8)
51+
strscan (>= 3.0.9)
52+
strscan (3.1.0)
53+
stud (0.0.23)
54+
thor (1.3.1)
55+
56+
PLATFORMS
57+
arm64-darwin-23
58+
ruby
59+
60+
DEPENDENCIES
61+
fpm
62+
package_cloud
63+
64+
RUBY VERSION
65+
ruby 3.3.1p55
66+
67+
BUNDLED WITH
68+
2.5.9

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
version: 2
33
updates:
4+
- package-ecosystem: "bundler"
5+
directory: "/.github"
6+
schedule:
7+
interval: "daily"
48
- package-ecosystem: "docker"
59
directory: "/"
610
schedule:

.github/workflows/bump-version.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: "bump-version"
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
bump_type:
9+
description: "Bump type"
10+
default: "patch"
11+
required: true
12+
type: choice
13+
options:
14+
- patch
15+
- minor
16+
- major
17+
18+
env:
19+
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
20+
21+
jobs:
22+
bump-version:
23+
name: bump-version
24+
runs-on: ubuntu-22.04
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/[email protected]
29+
with:
30+
fetch-depth: 0
31+
token: ${{ env.GITHUB_ACCESS_TOKEN }}
32+
33+
- name: Get Latest Tag
34+
id: latest-tag
35+
run: |
36+
echo GIT_LATEST_TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)")" >>"$GITHUB_OUTPUT"
37+
38+
- name: Compute Next Tag
39+
id: next-tag
40+
uses: docker://ghcr.io/dokku/semver-generator:latest
41+
with:
42+
bump: ${{ github.event.inputs.bump_type }}
43+
input: ${{ steps.latest-tag.outputs.GIT_LATEST_TAG }}
44+
45+
- name: Create and Push Tag
46+
run: |
47+
git config --global user.name 'Dokku Bot'
48+
git config --global user.email [email protected]
49+
git tag "$GIT_NEXT_TAG"
50+
git push origin "$GIT_NEXT_TAG"
51+
env:
52+
GIT_NEXT_TAG: ${{ steps.next-tag.outputs.version }}

.github/workflows/ci.yml

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,33 @@ name: CI
55
on:
66
pull_request:
77
branches:
8-
- '*'
8+
- "*"
99
push:
1010
branches:
11-
- 'master'
12-
- 'release'
11+
- "main"
1312

1413
jobs:
1514
build:
1615
name: build
1716
runs-on: ubuntu-22.04
18-
strategy:
19-
fail-fast: true
20-
2117
steps:
2218
- uses: actions/checkout@v4
2319

24-
- name: extract branch name
25-
shell: bash
26-
run: |
27-
if [[ "$GITHUB_REF" == *"/pull/"* ]]; then
28-
echo "branch=${GITHUB_HEAD_REF#refs/heads/}" >> $GITHUB_OUTPUT
29-
else
30-
echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
31-
fi
32-
id: extract_branch
33-
3420
- name: setup
3521
run: |
36-
make version
37-
if [[ "$CI_BRANCH" == "release" ]]; then
38-
export PACKAGECLOUD_REPOSITORY=dokku/dokku
39-
make .env.docker
40-
fi
41-
make ci-setup
22+
make version ci-setup
4223
env:
43-
CI_BRANCH: ${{ steps.extract_branch.outputs.branch }}
4424
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
4525
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
4626

4727
- name: build
4828
run: make build-docker-image build-in-docker
49-
env:
50-
CI_BRANCH: ${{ steps.extract_branch.outputs.branch }}
5129

5230
- name: test
5331
run: make validate-in-docker
54-
env:
55-
CI_BRANCH: ${{ steps.extract_branch.outputs.branch }}
5632

5733
- name: upload packages
5834
uses: actions/upload-artifact@v4
5935
with:
6036
name: build
6137
path: build
62-
63-
- name: release
64-
run: |
65-
if [[ "$CI_BRANCH" == "release" ]]; then
66-
make release-in-docker release-packagecloud-in-docker
67-
fi
68-
env:
69-
CI_BRANCH: ${{ steps.extract_branch.outputs.branch }}

.github/workflows/lint.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
name: 'lint'
2+
name: "lint"
33

44
# yamllint disable-line rule:truthy
55
on:
66
pull_request:
77
branches:
8-
- '*'
8+
- "*"
99
push:
1010
branches:
11-
- 'master'
11+
- "main"
1212

1313
jobs:
1414
hadolint:
@@ -19,7 +19,6 @@ jobs:
1919
uses: actions/checkout@v4
2020
- name: Run hadolint
2121
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf
22-
# v1.6.0 => d7b38582334d9ac11c12021c16f21d63015fa250
2322

2423
markdown-lint:
2524
name: markdown-lint
@@ -29,10 +28,9 @@ jobs:
2928
uses: actions/checkout@v4
3029
- name: Run markdown-lint
3130
uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb
32-
# v1.5.0 => 04d43ee9191307b50935a753da3b775ab695eceb
3331
with:
34-
config: '.github/linters/.markdown-lint.yml'
35-
args: './README.md'
32+
config: ".github/linters/.markdown-lint.yml"
33+
args: "./README.md"
3634

3735
shellcheck:
3836
name: shellcheck
@@ -42,7 +40,6 @@ jobs:
4240
uses: actions/checkout@v4
4341
- name: Run shellcheck
4442
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
45-
# 1.1.0 => 94e0aab03ca135d11a35e5bfc14e6746dc56e7e9
4643
env:
4744
SHELLCHECK_OPTS: -e SC2034
4845

@@ -54,7 +51,6 @@ jobs:
5451
uses: actions/checkout@v4
5552
- name: Run shfmt
5653
uses: luizm/action-sh-checker@c6edb3de93e904488b413636d96c6a56e3ad671a
57-
# v0.3.0 => 7f44869033b40ee4ffe7dc76c87a1bc66e3d025a
5854
env:
5955
SHFMT_OPTS: -l -bn -ci -i 2 -d
6056
with:
@@ -68,6 +64,5 @@ jobs:
6864
uses: actions/checkout@v4
6965
- name: Run yamllint
7066
uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c
71-
# v3.0.4 => ed2b6e911569708ed121c14b87d513860a7e36a7
7267
with:
73-
config_file: '.github/linters/.yamllint.yml'
68+
config_file: ".github/linters/.yamllint.yml"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
name: "tagged-release"
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
push:
7+
tags:
8+
- "*"
9+
10+
permissions:
11+
attestations: write
12+
id-token: write
13+
contents: write
14+
15+
jobs:
16+
tagged-release:
17+
name: tagged-release
18+
runs-on: ubuntu-22.04
19+
env:
20+
CI_BRANCH: release
21+
PACKAGECLOUD_REPOSITORY: dokku/dokku
22+
VERSION: ${{ github.ref_name }}
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Get Repository Name
29+
id: repo-name
30+
run: |
31+
echo "REPOSITORY_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)" >> $GITHUB_OUTPUT
32+
33+
- name: Build binaries
34+
run: |
35+
mkdir -p dist
36+
make version build/linux/${{ steps.repo-name.outputs.REPOSITORY_NAME }}
37+
cp build/linux/${{ steps.repo-name.outputs.REPOSITORY_NAME }} dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}
38+
39+
- name: Setup Ruby
40+
uses: ruby/[email protected]
41+
with:
42+
bundler-cache: true
43+
working-directory: .github
44+
45+
- name: Build Debian Packages
46+
run: |
47+
bundle exec make build/deb/${{ steps.repo-name.outputs.REPOSITORY_NAME }}_${{ github.ref_name }}_all.deb
48+
cp build/deb/*.deb dist/
49+
env:
50+
BUNDLE_GEMFILE: .github/Gemfile
51+
52+
- name: Upload Artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: dist
56+
path: dist/*
57+
58+
- name: Release to PackageCloud
59+
run: bundle exec make release-packagecloud
60+
env:
61+
BUNDLE_GEMFILE: .github/Gemfile
62+
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
63+
64+
- name: Release
65+
uses: softprops/action-gh-release@v2
66+
with:
67+
files: dist/*
68+
generate_release_notes: true
69+
make_latest: "true"

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ release-packagecloud:
127127
release-packagecloud-deb: build/deb/$(NAME)_$(VERSION)_all.deb
128128
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_all.deb
129129
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_all.deb
130+
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/noble build/deb/$(NAME)_$(VERSION)_all.deb
130131
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_all.deb
131132
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bookworm build/deb/$(NAME)_$(VERSION)_all.deb
132133
package_cloud push $(PACKAGECLOUD_REPOSITORY)/raspbian/bullseye build/deb/$(NAME)_$(VERSION)_all.deb

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# sshcommand
22

3-
[![Build Status](https://github.com/dokku/sshcommand/workflows/CI/badge.svg)](https://github.com/dokku/sshcommand/actions?query=workflow%3ACI)
4-
53
Simplifies running a single command over SSH, and manages authorized keys (ACL) and users in order to do so.
64

75
It basically simplifies running:

0 commit comments

Comments
 (0)