Skip to content

Commit

Permalink
Added semantic-release.
Browse files Browse the repository at this point in the history
  • Loading branch information
skyzyx committed Apr 10, 2024
1 parent 9fe66e8 commit 08f6470
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/build-semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

################################################################################
# DO NOT EDIT THIS FILE!
#
# 1. Edit the *.gotmpl.yml files instead.
# 2. go run generate-workflow.go -t _download-and-package.gotmpl.yml -p semantic-release -r 'go-semantic-release/semantic-release' -c '40 17 * * *'
################################################################################

name: "📦 Build semantic-release"
on:
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/workflows/build-semantic-release.yml"
- "packages/semantic-release/**"
pull_request:
branches: [main]
paths:
- ".github/workflows/build-semantic-release.yml"
- "packages/semantic-release/**"
schedule:
- cron: '40 17 * * *'

defaults:
run:
shell: bash

env:
DOCKER_BUILDKIT: 1
REGISTRY: ${{ vars.REGISTRY }}

permissions: read-all

jobs:
lookup:
runs-on: ubuntu-latest
name: Lookup current version
permissions:
packages: write
contents: read
strategy:
fail-fast: false

container:
image: ghcr.io/northwood-labs/package-builder/ubuntu-v22.04:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

outputs:
cache_hit: ${{ steps.check.outputs.cache-hit }}
package_version: ${{ steps.lookup_version.outputs.package_version }}

steps:
- name: Lookup latest version of package
id: lookup_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "package_version=$(download-asset latest-tag -r 'go-semantic-release/semantic-release' -s)" >> $GITHUB_OUTPUT
- name: Check to see if we've already built this version
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: check
with:
key: "semantic-release-${{ steps.lookup_version.outputs.package_version }}"
path: "packages/semantic-release/dist"
lookup-only: true

build:
if: needs.lookup.outputs.cache_hit != 'true'
needs: lookup
name: "📦 Build and cache"
uses: northwood-labs/package-building/.github/workflows/_build-and-cache.yml@main
secrets: inherit
with:
package-name: "semantic-release"
package-version: ${{ needs.lookup.outputs.package_version }}

upload:
if: needs.lookup.outputs.cache_hit != 'true'
needs: build
name: Upload to S3
uses: northwood-labs/package-building/.github/workflows/upload-to-s3.yml@main
secrets: inherit
with:
package-name: "semantic-release"
package-version: ${{ needs.lookup.outputs.package_version }}

metadata_rpm:
if: needs.lookup.outputs.cache_hit != 'true'
needs: upload
name: RPM metadata
uses: northwood-labs/package-building/.github/workflows/generate-rpm-meta.yml@main
secrets: inherit

metadata_deb:
if: needs.lookup.outputs.cache_hit != 'true'
needs: upload
name: DEB metadata
uses: northwood-labs/package-building/.github/workflows/generate-deb-meta.yml@main
secrets: inherit

metadata_apk:
if: needs.lookup.outputs.cache_hit != 'true'
needs: upload
name: APK metadata
uses: northwood-labs/package-building/.github/workflows/generate-apk-meta.yml@main
secrets: inherit
31 changes: 31 additions & 0 deletions packages/semantic-release/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# https://goreleaser.com/customization/project/
project_name: semantic-release

variables:
Vendor: semantic-release authors
VendorHomepage: https://go-semantic-release.xyz
License: MIT
Description: |
Semantic-release written in Go.
# https://goreleaser.com/customization/includes/
includes:
- from_file:
path: ../_dist.yml
- from_file:
path: ../_env.yml
- from_file:
path: ../_builds.yml
- from_file:
path: ../_nightly.yml
- from_file:
path: ../_nfpms.yml

# https://goreleaser.com/customization/hooks/
before:
hooks:
- cmd: |
bash ./download.sh
output: true
dir: .
18 changes: 18 additions & 0 deletions packages/semantic-release/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

# linux/amd64 (Intel64)
download-asset get \
--owner-repo "go-semantic-release/semantic-release" \
--pattern "semantic-release_v{{.Ver}}_linux_amd64" \
--archive-path "" \
--write-to-bin "semantic-release_amd64" \
;

# linux/arm64 (ARM64)
download-asset get \
--owner-repo "go-semantic-release/semantic-release" \
--pattern "semantic-release_v{{.Ver}}_linux_arm64" \
--archive-path "" \
--write-to-bin "semantic-release_arm64" \
;

0 comments on commit 08f6470

Please sign in to comment.