-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
155 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Create Release PR | ||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.0' # run this workflow when a new minor version is published | ||
workflow_dispatch: | ||
inputs: | ||
release_version: | ||
description: '馃 Which version are we creating a release pull request for?' | ||
required: true | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
create-release-pull-request: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.20 | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20 | ||
|
||
- name: Set release version and target branch for vNext | ||
if: github.event_name == 'push' | ||
run: | | ||
TAG="$(echo "${{ github.ref }}" | tr -d 'refs/tags/v')" | ||
MAJOR_VERSION="$(echo "${TAG}" | cut -d '.' -f1)" | ||
echo "MAJOR_VERSION=${MAJOR_VERSION}" >> ${GITHUB_ENV} | ||
MINOR_VERSION="$(echo "${TAG}" | cut -d '.' -f2)" | ||
echo "MINOR_VERSION=${MINOR_VERSION}" >> ${GITHUB_ENV} | ||
# increment the minor version by 1 for vNext | ||
echo "NEWVERSION=v${MAJOR_VERSION}.$((MINOR_VERSION+1)).0-beta.0" >> ${GITHUB_ENV} | ||
# pre-release is always being merged to the main branch | ||
echo "TARGET_BRANCH=main" >> ${GITHUB_ENV} | ||
- name: Set release version and target branch from input | ||
if: github.event_name == 'workflow_dispatch' | ||
run: | | ||
NEWVERSION="${{ github.event.inputs.release_version }}" | ||
echo "${NEWVERSION}" | grep -E '^v[0-9]+\.[0-9]+\.[0-9](-(beta|rc)\.[0-9]+)?$' || (echo "release_version should be in the format vX.Y.Z, vX.Y.Z-beta.A, or vX.Y.Z-rc.B" && exit 1) | ||
echo "NEWVERSION=${NEWVERSION}" >> ${GITHUB_ENV} | ||
MAJOR_VERSION="$(echo "${NEWVERSION}" | cut -d '.' -f1 | tr -d 'v')" | ||
MINOR_VERSION="$(echo "${NEWVERSION}" | cut -d '.' -f2)" | ||
# non-beta releases should always be merged to release branches | ||
echo "TARGET_BRANCH=release-${MAJOR_VERSION}.${MINOR_VERSION}" >> ${GITHUB_ENV} | ||
# beta releases should always be merged to main | ||
if [[ "${NEWVERSION}" =~ "beta" ]]; then | ||
echo "TARGET_BRANCH=main" >> ${GITHUB_ENV} | ||
fi | ||
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create release branch if needed | ||
run: | | ||
git checkout "${TARGET_BRANCH}" && exit 0 | ||
# Create and push release branch if it doesn't exist | ||
git checkout -b "${TARGET_BRANCH}" | ||
git push --set-upstream origin "${TARGET_BRANCH}" | ||
- run: make release-manifest | ||
|
||
- if: github.event_name == 'push' | ||
run: make version-docs NEWVERSION=v${MAJOR_VERSION}.${MINOR_VERSION}.x | ||
|
||
- name: Create release pull request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
commit-message: "chore: Prepare ${{ env.NEWVERSION }} release" | ||
title: "chore: Prepare ${{ env.NEWVERSION }} release" | ||
branch: "release-${{ env.NEWVERSION }}" | ||
base: "${{ env.TARGET_BRANCH }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,30 @@ | ||
name: Publish release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: write | ||
steps: | ||
- name: Validate release branch name | ||
run: | | ||
echo "Publish release invoked on $GITHUB_REF_NAME ..." | ||
set +e | ||
BASE_BRANCH=$(echo "$GITHUB_REF_NAME" | grep -E '^(main|release-[0-9]+\.[0-9]+)$') | ||
if [ -z "$BASE_BRANCH" ]; then echo "Release workflow must be run on \`main\` or \`release-X.Y\` branches ..."; exit 1; | ||
else echo "BASE_BRANCH=$BASE_BRANCH" >> $GITHUB_ENV; | ||
fi | ||
- name: Check out repo | ||
uses: actions/checkout@v3 | ||
- name: Calculate new version number | ||
uses: go-semantic-release/action@1b14387401a1c3b588c807afd4ba4a921fd9cc31 | ||
id: semrel | ||
- uses: actions/checkout@v3 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
allow-initial-development-versions: true | ||
custom-arguments: '--no-ci' | ||
dry: true | ||
- name: Validate appropriate base branch for release | ||
run: | | ||
if [ -z "${{ steps.semrel.outputs.version }}" ]; then | ||
echo "No relevant changes found to publish new release against" | ||
exit 1 | ||
fi | ||
RELEASE_BRANCH_VER="${{ steps.semrel.outputs.version_major }}.${{ steps.semrel.outputs.version_minor }}" | ||
if [ "$BASE_BRANCH" == 'main' ]; then | ||
if [ ${{ steps.semrel.outputs.version_patch }} != '0' ]; then | ||
echo "Patch revisions should be published off the appropriate release branch, not main" | ||
exit 1 | ||
fi | ||
echo "Publishing new release branch ${{ steps.semrel.outputs.version }} from $BASE_BRANCH ..." | ||
else | ||
BASE_BRANCH_VER="$(echo "$BASE_BRANCH" | grep -Po '(?<=release-)[0-9]+\.[0-9]+$')" | ||
if [ "$RELEASE_BRANCH_VER" != "$BASE_BRANCH_VER" ]; then | ||
echo "New major/minor versions should be published off main, not an existing release branch" | ||
exit 1 | ||
fi | ||
echo "Publishing revision ${{ steps.semrel.outputs.version }} for $BASE_BRANCH ..." | ||
fi | ||
echo "RELEASE_BRANCH_VER=$RELEASE_BRANCH_VER" >> GITHUB_ENV | ||
- name: Set up golang | ||
uses: actions/setup-go@v4 | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.19 | ||
- name: Build release | ||
run: | | ||
CLI_VERSION="${{ steps.semrel.outputs.version }}" make release version-docs | ||
- name: Create new semantic release | ||
uses: go-semantic-release/action@1b14387401a1c3b588c807afd4ba4a921fd9cc31 | ||
go-version: "1.20" | ||
|
||
- uses: anchore/sbom-action/download-syft@v0 | ||
|
||
- name: Run goreleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
allow-initial-development-versions: true | ||
custom-arguments: '--no-ci' | ||
- name: Upload packages | ||
uses: AButler/upload-release-assets@c94805dc72e4b20745f543da0f62eaee7722df7a | ||
with: | ||
files: 'dist/linux_amd64/release/copa_*' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
release-tag: 'v${{ steps.semrel.outputs.version }}' | ||
- name: Create new release branch if needed (idempotent) | ||
uses: peterjgrainger/action-create-branch@08259812c8ebdbf1973747f9297e332fa078d3c1 | ||
version: latest | ||
args: release --clean --config .goreleaser.yml | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
branch: release-${{ steps.semrel.outputs.version_major }}.${{ steps.semrel.outputs.version_minor }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
project_name: copacetic | ||
builds: | ||
- id: copacetic | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
env: | ||
- CGO_ENABLED=0 | ||
- GO111MODULE=on | ||
ldflags: -s -w | ||
-X github.com/project-copacetic/copacetic/pkg/version.GitVersion={{.Version}} | ||
-X github.com/project-copacetic/copacetic/pkg/version.GitCommit={{.Commit}} | ||
-X github.com/project-copacetic/copacetic/pkg/version.BuildDate={{.Date}} | ||
-X main.Version=$(.Version) | ||
-extldflags "-static" | ||
binary: copa | ||
hooks: {} | ||
|
||
archives: | ||
- id: copacetic | ||
builds: | ||
- copacetic | ||
format: tar.gz | ||
name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}" | ||
|
||
checksum: | ||
name_template: "{{ .ProjectName }}_checksums.txt" | ||
algorithm: sha256 | ||
|
||
sboms: | ||
- artifacts: archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters