diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4cac744..fb1571e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: with: go-version: "1.22.2" - - name: Install depedencies + - name: Install dependencies run: sudo apt-get install libbtrfs-dev -y - name: Download Go Modules diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bedf9a0 --- /dev/null +++ b/.github/workflows/release.yml @@ -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/add-and-commit@v9.1.4 + with: + author_name: monty-bot + author_email: monty-bot@arm.com + 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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..849ddff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..b612f2f --- /dev/null +++ b/.goreleaser.yaml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/changes/README.md b/changes/README.md new file mode 100644 index 0000000..a5af014 --- /dev/null +++ b/changes/README.md @@ -0,0 +1,31 @@ + +# 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 `.`, 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 | \ No newline at end of file diff --git a/changes/version.properties b/changes/version.properties new file mode 100644 index 0000000..53b2cba --- /dev/null +++ b/changes/version.properties @@ -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 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1cc63bf --- /dev/null +++ b/pyproject.toml @@ -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"