Skip to content

Commit

Permalink
Incorporate full git details about the reva version being built
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed May 6, 2024
1 parent 452320f commit 8a5b4f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@ jobs:
- name: Install golang
run: |
wget https://go.dev/dl/go${{ inputs.go-version }}.linux-amd64.tar.gz && tar xfz go${{ inputs.go-version }}.linux-amd64.tar.gz
- name: Bump version in spec file
run: |
export GOPATH=$(pwd)/go
export PATH=$PATH:$GOPATH/bin
cd reva-release
go run prepare_release.go -author "cernbox-admins[bot]" -email "[email protected]"
echo "version=$(awk '$1 == "Version:" {print $2}' cernbox-revad.spec)" >> $GITHUB_ENV
- name: Checkout reva repository
uses: actions/checkout@v3
with:
repository: ${{ inputs.repo }}/reva
path: reva
ref: ${{ inputs.branch }}
- name: Bump version in spec file
run: |
export GOPATH=$(pwd)/go
export PATH=$PATH:$GOPATH/bin
cd reva
export REVAVER="$(git describe --always) commit $(git rev-parse --short HEAD) at ${{ inputs.branch }}/${{ inputs.repo }}"
cd ../reva-release
go run prepare_release.go -author "cernbox-admins[bot]" -email "[email protected]" -reva-version "$REVAVER"
echo "version=$(awk '$1 == "Version:" {print $2}' cernbox-revad.spec)" >> $GITHUB_ENV
- name: Copy necessary files for building the RPMs
run: |
cp reva-release/Makefile reva/Makefile.rpm
Expand Down
19 changes: 10 additions & 9 deletions prepare_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ import (
)

var (
author = flag.String("author", "", "the author that creates the release")
email = flag.String("email", "", "the email of the authot that creates the release")
versionTag = flag.String("version-tag", "", "the tag of the version")
version = flag.String("version", "0", "version to tag")
author = flag.String("author", "", "the author that creates the release")
email = flag.String("email", "", "the email of the authot that creates the release")
versionTag = flag.String("version-tag", "", "the tag of the version")
version = flag.String("version", "0", "version to tag")
revaVersion = flag.String("reva-version", "", "the reva version and commt")
)

const (
Expand All @@ -47,21 +48,21 @@ const (
func init() {
flag.Parse()

if *author == "" || *email == "" {
fmt.Fprintln(os.Stderr, "fill the author and email flags")
if *author == "" || *email == "" || *revaVersion == "" {
fmt.Fprintln(os.Stderr, "fill the author, email, and revaVersion flags")
os.Exit(1)
}
}

func main() {
err := releaseNewVersion(*author, *email)
err := releaseNewVersion(*author, *email, *revaVersion)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func releaseNewVersion(author, email string) error {
func releaseNewVersion(author, email, revaVersion string) error {
specContent, err := readSpecFile()
if err != nil {
return fmt.Errorf("error reading spec content: %w", err)
Expand Down Expand Up @@ -94,7 +95,7 @@ func releaseNewVersion(author, email string) error {
var newChangelog []string
today := time.Now().Format("Mon Jan 02 2006")
newChangelog = append(newChangelog, fmt.Sprintf("* %s %s <%s> %s", today, author, email, versionStr))
newChangelog = append(newChangelog, fmt.Sprintf("- v%s", versionStr))
newChangelog = append(newChangelog, fmt.Sprintf("- v%s, based on reva %s", versionStr, revaVersion))

var newSpec []string
newSpec = append(newSpec, specContent[:changelogHeader+1]...)
Expand Down

0 comments on commit 8a5b4f3

Please sign in to comment.