Fix goreleaser issues and add new goreleaser action.

Fix goreleaser script's bug.
Add a new Github action to verify goreleaser related modification.

Signed-off-by: Xun Jiang <blackpiglet@gmail.com>
pull/6109/head
Xun Jiang 2023-04-11 16:27:58 +08:00
parent bacec117b9
commit e779cd2b76
6 changed files with 46 additions and 10 deletions

29
.github/workflows/pr-goreleaser.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Verify goreleaser change
on:
pull_request:
branches:
- 'main'
- 'release-**'
paths:
- '.goreleaser.yml'
- 'hack/release-tools/goreleaser.sh'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout
- name: Verify .goreleaser.yml and try a dryrun release.
if: github.repository == 'vmware-tanzu/velero'
run: |
CHANGELOG=$(ls changelogs | sort -V -r | head -n 1)
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
REGISTRY=velero \
RELEASE_NOTES_FILE=changelogs/$CHANGELOG \
PUBLISH=false \
make release

View File

@ -46,6 +46,9 @@ archives:
files: files:
- LICENSE - LICENSE
- examples/**/* - examples/**/*
# Add the setting to resolve the DEPRECATED warning. Actually, Velero's case is not affected by the rlcp behavior change.
# https://github.com/orgs/goreleaser/discussions/3659#discussioncomment-4587257
rlcp: true
checksum: checksum:
name_template: 'CHECKSUM' name_template: 'CHECKSUM'
release: release:
@ -54,3 +57,10 @@ release:
name: velero name: velero
draft: true draft: true
prerelease: auto prerelease: auto
git:
# What should be used to sort tags when gathering the current and previous
# tags if there are more than one tag in the same commit.
#
# Default: `-version:refname`
tag_sort: -version:creatordate

View File

@ -0,0 +1 @@
Fix the goreleaser issues and add a new goreleaser action

View File

@ -50,7 +50,7 @@ RUN wget --quiet https://github.com/protocolbuffers/protobuf/releases/download/v
RUN go install github.com/golang/protobuf/protoc-gen-go@v1.4.3 RUN go install github.com/golang/protobuf/protoc-gen-go@v1.4.3
# get goreleaser # get goreleaser
RUN wget --quiet https://github.com/goreleaser/goreleaser/releases/download/v1.12.3/goreleaser_Linux_x86_64.tar.gz && \ RUN wget --quiet https://github.com/goreleaser/goreleaser/releases/download/v1.15.2/goreleaser_Linux_x86_64.tar.gz && \
tar xvf goreleaser_Linux_x86_64.tar.gz && \ tar xvf goreleaser_Linux_x86_64.tar.gz && \
mv goreleaser /usr/bin/goreleaser && \ mv goreleaser /usr/bin/goreleaser && \
chmod +x /usr/bin/goreleaser chmod +x /usr/bin/goreleaser

View File

@ -41,6 +41,10 @@ else
export GIT_TREE_STATE=dirty export GIT_TREE_STATE=dirty
fi fi
# Verify .goreleaser.yml format first.
echo "Start to verify .goreleaser.yml format"
goreleaser check
# $PUBLISH must explicitly be set to 'TRUE' for goreleaser # $PUBLISH must explicitly be set to 'TRUE' for goreleaser
# to publish the release to GitHub. # to publish the release to GitHub.
if [[ "${PUBLISH:-}" != "TRUE" ]]; then if [[ "${PUBLISH:-}" != "TRUE" ]]; then
@ -48,12 +52,10 @@ if [[ "${PUBLISH:-}" != "TRUE" ]]; then
goreleaser release \ goreleaser release \
--clean \ --clean \
--release-notes="${RELEASE_NOTES_FILE}" \ --release-notes="${RELEASE_NOTES_FILE}" \
--skip-publish \ --snapshot # Generate an unversioned snapshot release, skipping all validations and without publishing any artifacts (implies --skip-publish, --skip-announce and --skip-validate)
--config goreleaser.yaml
else else
echo "Getting ready to publish" echo "Getting ready to publish"
goreleaser release \ goreleaser release \
--clean \ --clean \
--release-notes="${RELEASE_NOTES_FILE}" --release-notes="${RELEASE_NOTES_FILE}"
--config goreleaser.yaml
fi fi

View File

@ -1,6 +0,0 @@
git:
# What should be used to sort tags when gathering the current and previous
# tags if there are more than one tag in the same commit.
#
# Default: `-version:refname`
tag_sort: -version:creatordate