Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
ci(publish): add .goreleaser.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Jul 18, 2023
1 parent 39a125b commit 7875c26
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 109 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
121 changes: 27 additions & 94 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,109 +6,42 @@ on:
- "*"

jobs:
publish-macos:
create-release:
name: Create GitHub release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create release
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ contains(github.ref, '-') }}

publish:
name: Publish for ${{ matrix.os }}
needs: [create-release]
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
artifact_name: ovt
asset_name: ouverture-macos-amd64

steps:
- uses: actions/checkout@v1

- name: Build
run: swift build -c release

- name: Zip
run: tar czvf ${{ matrix.asset_name }}.tar.gz -C ./.build/release ${{ matrix.artifact_name }}

- name: Generate sha256
run: openssl dgst -r -sha256 ${{ matrix.asset_name }}.tar.gz > ${{ matrix.asset_name }}.tar.gz.sha256

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.asset_name }}.tar.gz
asset_name: ${{ matrix.asset_name }}.tar.gz
tag: ${{ github.ref }}
overwrite: true

- name: Upload sha256 to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.asset_name }}.tar.gz.sha256
asset_name: ${{ matrix.asset_name }}.tar.gz.sha256
tag: ${{ github.ref }}
overwrite: true

bump-tap-version:
name: Generate new ruby script for homebrew tap
needs: [publish-macos]
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- run: npm i @actions/core @actions/github

- name: Get "version"
id: ver
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Check "version"
env:
RELEASE_VERSION: ${{ steps.ver.outputs.tag }}
run: |
echo "Detected version:"
echo $RELEASE_VERSION
- name: Get tarball file name
id: binaries
env:
BIN_MAC: ouverture-macos-amd64.tar.gz
run: |
echo ::set-output name=mac::$BIN_MAC
- uses: actions/checkout@v3

- name: Get url
id: url
env:
URL_MAC: https://github.com/${{ github.repository }}/releases/download/${{ steps.ver.outputs.tag }}/${{ steps.binaries.outputs.mac }}
run: |
echo ::set-output name=mac::$URL_MAC
- name: Setup Swift
uses: swift-actions/setup-swift@v1

- name: Get files and checksums
id: checksums
# https://liamnichols.eu/2020/08/01/building-swift-packages-as-a-universal-binary.html
- name: Build
run: |
curl -LO ${{ steps.url.outputs.mac }}.sha256
echo ::set-output name=mac::$(cat ${{ steps.binaries.outputs.mac }}.sha256 | awk '{ print $1 }')
- name: Replace variables in template
uses: rami3l/bumper@master
id: replace
with:
template: "Dist/brew/template.rb"
out: "ouverture.rb"

rules: |
{
"version": "${{ steps.ver.outputs.tag }}",
"url_mac": "${{ steps.url.outputs.mac }}",
"sha256_mac": "${{ steps.checksums.outputs.mac }}"
}
swift build -c release --arch arm64 --arch x86_64
- name: Get the output script
run: cat ouverture.rb

- name: Upload the script to release
uses: svenstaro/upload-release-action@v1-release
# https://goreleaser.com/ci/actions/?h=github+act#usage
- name: Publish via GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "ouverture.rb"
asset_name: "ouverture.rb"
tag: ${{ github.ref }}
overwrite: true
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
26 changes: 22 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: test

on:
push:
branches: [master]
branches: ["master"]
pull_request:
branches: [master]
branches: ["master"]

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Swift
uses: swift-actions/setup-swift@v1

# src: https://harry.garrood.me/blog/easy-incremental-haskell-ci-builds-with-ghc-9.4/
- name: Cache build
uses: actions/cache@v3
with:
path: |
.build
key: build-${{ runner.os }}-${{ hashFiles('Package.swift') }}-${{ hashFiles('Package.resolved') }}
restore-keys: |
build-${{ runner.os }}-${{ hashFiles('Package.swift') }}
- name: Build
run: swift build -v

- name: Run tests
run: swift test -Xswiftc -DFULL
run: swift test -v
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ fastlane/test_output

iOSInjectionProject/
.DS_Store

# GoReleaser
dist/
76 changes: 76 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# Adapted from https://github.com/LGUG2Z/komorebi/blob/e240bc770619fa7c1f311b8a376551f2dde8a2d7/.goreleaser.yml
project_name: ouverture

before:
hooks:
- bash -c 'echo "package main; func main() {}" > dummy.go'

builds:
- id: ouverture
binary: ovt
main: dummy.go
# env:
# - CGO_ENABLED=0
goos:
- darwin
goarch:
- amd64
- arm64

universal_binaries:
- replace: true
id: ouverture
hooks:
post:
- mkdir -p ./dist/ouverture_darwin_all
- bash -c 'cp "$(swift build --show-bin-path -c release --arch arm64 --arch x86_64)/ovt" ./dist/ouverture_darwin_all/ovt'

archives:
- format: tar.gz
# https://goreleaser.com/customization/archive/#packaging-only-the-binaries
files:
- none*
name_template: >-
{{ .ProjectName }}_
{{- .Os }}_
{{- if eq .Arch "all" }}universal2
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
# Use zip for windows archives
- goos: windows
format: zip

checksum:
name_template: "checksums.txt"

brews:
# https://goreleaser.com/customization/homebrew/
- homepage: https://github.com/rami3l/Ouverture
description: A default application modifier for macOS.
license: BSD-2-Clause

install: |
bin.install "ovt"
test: |
system "#{bin}/ovt"
skip_upload: auto

# https://github.com/goreleaser/goreleaser/blob/a0f0d01a8143913cde72ebc1248abef089ae9b27/.goreleaser.yaml#L211
repository:
owner: rami3l
name: homebrew-tap
branch: "{{.ProjectName}}-{{.Version}}"
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
pull_request:
enabled: true
base:
owner: rami3l
name: homebrew-tap
branch: master
11 changes: 0 additions & 11 deletions Dist/brew/template.rb

This file was deleted.

25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2023, rami3l
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 comments on commit 7875c26

Please sign in to comment.