Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflow #5

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
go-version: "1.22.2"

sm-powell marked this conversation as resolved.
Show resolved Hide resolved
- name: Install depedencies
- name: Install dependencies
run: sudo apt-get install libbtrfs-dev -y

- name: Download Go Modules
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: GitHub Release

on:
workflow_dispatch:

env:
go-version: '1.22.2'
python-version: '3.10'

jobs:
# News file based version calculation
create-release:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:

- uses: tibdex/github-app-token@v2
id: get_installation_token
with:
app_id: 366894
private_key: ${{ secrets.OTG_PLATFORM_APP_PRIVATE_KEY }}

# Checkout with full history so commit number can be calculated for beta versions
- uses: actions/checkout@v4
with:
token: ${{ steps.get_installation_token.outputs.token }}
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.go-version }}

# Towncrier and CI tools are written in Python
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}

- name: Install CI tools
run: pip install continuous-delivery-scripts

- name: Generate release notes from news files
run: cd-generate-news --release-type release

- name: Determine version number based on news files
run: |
echo "SEMVER_VERSION=$(cd-determine-version --release-type release)" >> $GITHUB_ENV
- name: Report version number for run
run: |
echo "::notice:: Releasing $SEMVER_VERSION"

- name: Commit changes
uses: EndBug/[email protected]
with:
author_name: monty-bot
sm-powell marked this conversation as resolved.
Show resolved Hide resolved
author_email: [email protected]
message: "Release v${{ env.SEMVER_VERSION }} [skip ci]"
add: "changes"
tag: "v${{ env.SEMVER_VERSION }} -m 'Release v${{ env.SEMVER_VERSION }}'"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
49 changes: 49 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Goreleaser config for Armer
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
draft: true
replace_existing_draft: true
Empty file added CHANGELOG.md
Empty file.
31 changes: 31 additions & 0 deletions changes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->
# Changes directory

This directory comprises information about all the changes that happened since the last release.

A news file should be added to this directory for each PR.

On release of the action, the content of the file becomes part of the [change log](../CHANGELOG.md) and this directory is reset.

## News Files

News files serve a different purpose to commit messages, which are generally written to inform developers of the
project. News files will form part of the release notes so should be written to target the consumer of the GitHub action.

- At least, one news file should be added for each Merge/Pull request to the directory `/changes`.
- The text of the file should be a single line describing the change and/or impact to the user.
- The filename of the news file should take the form `<number>.<extension>`, e.g, `20191231.feature` where:
- The number is either the issue number or, if no issue exists, the date in the form `YYYYMMDDHHMM`.
- The extension should indicate the type of change as described in the following table:

| Change Type | Extension | Version Impact |
|-------------------------------------------------------------------------------------------------------------------------|------------|-----------------|
| Backwards compatibility breakages or significant changes denoting a shift direction. | `.major` | Major increment |
| New features and enhancements (non breaking). | `.feature` | Minor increment |
| Bug fixes or corrections (non breaking). | `.bugfix` | Patch increment |
| Documentation impacting the consumer of the package (not repo documentation, such as this file, for this use `.misc`). | `.doc` | N/A |
| Deprecation of functionality or interfaces (not actual removal, for this use `.major`). | `.removal` | None |
| Changes to the repository that do not impact functionality e.g. build scripts change. | `.misc` | None |
6 changes: 6 additions & 0 deletions changes/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Semantic version number is automatically maintained by creating news files and releasing via CI.
VERSION=0.0.0
COMMIT=bdf3f63700313295382f1e9c896f1a3bf9e1cbaa
MAJOR=0
MINOR=0
PATCH=0
70 changes: 70 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[ProjectConfig]
MASTER_BRANCH = "main"
PROJECT_NAME = "armer"
PROJECT_ROOT = "."
PROJECT_UUID = "576e054b-f0a7-4ae8-be5c-090de20ed0ca"
NEWS_DIR = "changes/"
RELEASE_BRANCH_PATTERN = "*"
VERSION_FILE_PATH = "changes/version.properties"
CHANGELOG_FILE_PATH = "CHANGELOG.md"
PROGRAMMING_LANGUAGE = "go"

AWS_BUCKET=""
SOURCE_DIR = ""
MODULE_TO_DOCUMENT = ""
DOCUMENTATION_DEFAULT_OUTPUT_PATH = "./does-not-exist"
DOCUMENTATION_PRODUCTION_OUTPUT_PATH = "./does-not-exist"

[tool.towncrier]
directory = "changes"
filename = "CHANGELOG.md"
title_format = false

[[tool.towncrier.type]]
directory = "major"
name = "Major changes"
showcontent = true

[[tool.towncrier.type]]
directory = "feature"
name = "Features"
showcontent = true

[[tool.towncrier.type]]
directory = "bugfix"
name = "Bugfixes"
showcontent = true

[[tool.towncrier.type]]
directory = "doc"
name = "Improved Documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "removal"
name = "Deprecations and Removals"
showcontent = true

[[tool.towncrier.type]]
directory = "misc"
name = "Misc"
showcontent = false

[AutoVersionConfig]
CONFIG_NAME = "DEFAULT"
PRERELEASE_TOKEN = "beta"
BUILD_TOKEN = "dev"
TAG_TEMPLATE = "v{version}"
targets = [ "changes/version.properties",]

[AutoVersionConfig.key_aliases]
VERSION = "VERSION_KEY"
MAJOR = "major"
MINOR = "minor"
PATCH = "patch"
COMMIT = "COMMIT"

[AutoVersionConfig.trigger_patterns]
major = "changes/*.major"
minor = "changes/*.feature"
patch = "changes/*.bugfix"