Skip to content

Commit

Permalink
Merge pull request #148 from dokku/automate-releases
Browse files Browse the repository at this point in the history
feat: add ability to create releases from a github workflow
  • Loading branch information
josegonzalez authored May 18, 2024
2 parents 635a79d + 9d26f20 commit a6915c4
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 14 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[Makefile]
insert_final_newline = true
indent_style = tab
indent_size = 4

[*.go]
insert_final_newline = true
indent_style = tab
indent_size = 4
1 change: 1 addition & 0 deletions .github/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.1
6 changes: 6 additions & 0 deletions .github/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

ruby file: ".ruby-version"

gem "fpm"
gem "package_cloud"
68 changes: 68 additions & 0 deletions .github/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
GEM
remote: https://rubygems.org/
specs:
arr-pm (0.0.12)
backports (3.25.0)
cabin (0.9.0)
clamp (1.0.1)
domain_name (0.6.20240107)
dotenv (3.1.2)
fpm (1.15.1)
arr-pm (~> 0.0.11)
backports (>= 2.6.2)
cabin (>= 0.6.0)
clamp (~> 1.0.0)
pleaserun (~> 0.0.29)
rexml
stud
highline (2.0.3)
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
insist (1.0.0)
json_pure (2.3.1)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0507)
mustache (0.99.8)
netrc (0.11.0)
package_cloud (0.3.14)
highline (~> 2.0.0)
json_pure (~> 2.3.0)
rainbow (= 2.2.2)
rest-client (~> 2.0)
thor (~> 1.2)
pleaserun (0.0.32)
cabin (> 0)
clamp
dotenv
insist
mustache (= 0.99.8)
stud
rainbow (2.2.2)
rake
rake (13.2.1)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.8)
strscan (>= 3.0.9)
strscan (3.1.0)
stud (0.0.23)
thor (1.3.1)

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
fpm
package_cloud

RUBY VERSION
ruby 3.3.1p55

BUNDLED WITH
2.5.9
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
version: 2
updates:
- package-ecosystem: "bundler"
directory: "/.github"
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/"
schedule:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: "bump-version"

# yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
bump_type:
description: "Bump type"
default: "patch"
required: true
type: choice
options:
- patch
- minor
- major

env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

jobs:
bump-version:
name: bump-version
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4.1.4
with:
fetch-depth: 0
token: ${{ env.GITHUB_ACCESS_TOKEN }}

- name: Get Latest Tag
id: latest-tag
run: |
echo GIT_LATEST_TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)")" >>"$GITHUB_OUTPUT"
- name: Compute Next Tag
id: next-tag
uses: docker://ghcr.io/dokku/semver-generator:latest
with:
bump: ${{ github.event.inputs.bump_type }}
input: ${{ steps.latest-tag.outputs.GIT_LATEST_TAG }}

- name: Create and Push Tag
run: |
git config --global user.name 'Dokku Bot'
git config --global user.email no-reply@dokku.com
git tag "$GIT_NEXT_TAG"
git push origin "$GIT_NEXT_TAG"
env:
GIT_NEXT_TAG: ${{ steps.next-tag.outputs.version }}
10 changes: 0 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
build:
name: build
runs-on: ubuntu-20.04
strategy:
fail-fast: true
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
Expand All @@ -33,11 +31,3 @@ jobs:
with:
name: build
path: build/**/*
- name: make release-in-docker
run: |
if [[ "${GITHUB_REF#refs/heads/}" == "release" ]]; then
export CI_BRANCH=${GITHUB_REF#refs/heads/}
export PACKAGECLOUD_REPOSITORY=dokku/dokku
rm .env.docker
make .env.docker release-in-docker release-packagecloud-in-docker
fi
114 changes: 114 additions & 0 deletions .github/workflows/tagged-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
name: "tagged-release"

# yamllint disable-line rule:truthy
on:
push:
tags:
- "*"

permissions:
attestations: write
id-token: write
contents: write

jobs:
tagged-release:
name: tagged-release
runs-on: ubuntu-22.04
env:
CI_BRANCH: release
PACKAGECLOUD_REPOSITORY: dokku/dokku
VERSION: ${{ github.ref_name }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Get Repository Name
id: repo-name
run: |
echo "REPOSITORY_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)" >> $GITHUB_OUTPUT
- name: Build binaries
uses: crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: 1.21
dest: dist
prefix: ${{ steps.repo-name.outputs.REPOSITORY_NAME }}
targets: darwin/amd64,darwin/arm64,linux/arm64,linux/amd64
v: true
x: false
race: false
ldflags: -s -w -X main.Version=${{ github.ref_name }}
buildmode: default
trimpath: true

- name: Attest Build Provenance - darwin-amd64
uses: actions/attest-build-provenance@v1.1.2
with:
subject-path: "dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-darwin-amd64"

- name: Attest Build Provenance - darwin-arm64
uses: actions/attest-build-provenance@v1.1.2
with:
subject-path: "dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-darwin-arm64"

- name: Attest Build Provenance - linux-amd64
uses: actions/attest-build-provenance@v1.1.2
with:
subject-path: "dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-linux-amd64"

- name: Attest Build Provenance - linux-arm64
uses: actions/attest-build-provenance@v1.1.2
with:
subject-path: "dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-linux-arm64"

- name: Attest Build Provenance - windows-amd64
uses: actions/attest-build-provenance@v1.1.2
with:
subject-path: "dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-windows-amd64.exe"

- name: Setup Ruby
uses: ruby/setup-ruby@v1.176.0
with:
bundler-cache: true
working-directory: .github

- name: Build Debian Packages
run: |
mkdir -p build/linux
cp dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-linux-amd64 build/linux/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-amd64
cp dist/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-linux-arm64 build/linux/${{ steps.repo-name.outputs.REPOSITORY_NAME }}-arm64
bundle exec make build/deb/${{ steps.repo-name.outputs.REPOSITORY_NAME }}_${{ github.ref_name }}_arm64.deb
bundle exec make build/deb/${{ steps.repo-name.outputs.REPOSITORY_NAME }}_${{ github.ref_name }}_amd64.deb
cp build/deb/*.deb dist/
env:
BUNDLE_GEMFILE: .github/Gemfile

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*

- name: Release to PackageCloud
run: bundle exec make release-packagecloud
env:
BUNDLE_GEMFILE: .github/Gemfile
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

- name: Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
make_latest: "true"
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ release-packagecloud:
release-packagecloud-deb: build/deb/$(NAME)_$(VERSION)_amd64.deb build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/noble build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bookworm build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/noble build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bookworm build/deb/$(NAME)_$(VERSION)_arm64.deb

Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module plugn

go 1.18
go 1.21

toolchain go1.22.2

require (
github.com/BurntSushi/toml v1.3.2
github.com/dokku/duplex v0.0.0-20160916172127-5bc6cb8042f7
github.com/progrium/go-basher v5.1.6+incompatible
github.com/progrium/go-basher v5.1.7+incompatible
github.com/progrium/plugin-demo v0.0.0-20160206152045-d94df2206a64
)

Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/progrium/crypto v0.0.0-20141231035031-e04455474e32 h1:TazRiCelU8NoJMn2z0/RIzv4lUUkp5YwAunbjUsODHQ=
github.com/progrium/crypto v0.0.0-20141231035031-e04455474e32/go.mod h1:spjB7wUvxDfIjoK9jtlCu07B/QaZwjtKlQeM3njS9QA=
github.com/progrium/go-basher v5.1.6+incompatible h1:4C9YrvISyUN01W2gEruN1EzMecc75NDiHUjipKuOqls=
github.com/progrium/go-basher v5.1.6+incompatible/go.mod h1:Oiy7jZEU1mm+gI1dt5MKYwxptmD37q8/UupxnwhMHtI=
github.com/progrium/go-basher v5.1.7+incompatible h1:0ezYhhUW4Ie0h5faBKZWq+Ajn9VyR7mGI3ayi7khS7c=
github.com/progrium/go-basher v5.1.7+incompatible/go.mod h1:Oiy7jZEU1mm+gI1dt5MKYwxptmD37q8/UupxnwhMHtI=
github.com/progrium/plugin-demo v0.0.0-20160206152045-d94df2206a64 h1:FHNCTel7Yt0+4I1uvKfu2X+g8U8tHBBJb7zl+ohfmqM=
github.com/progrium/plugin-demo v0.0.0-20160206152045-d94df2206a64/go.mod h1:xwVfSlPMRhFysvnn0lOZ1Ruen2jTuzgwm4Hs0onTrlY=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=

0 comments on commit a6915c4

Please # to comment.