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

Create release action for sda-admin #1094

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .github/workflows/build_pr_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- ".github/dependabot.yaml"
- "charts/**"
- "Makefile"
- "sda-admin/*"

env:
PR_NUMBER: ${{ github.event.number }}
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/release_sda-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release sda-admin

on:
merge_group:
pull_request:
paths:
- 'sda-admin/.version'
types: [ closed ]
workflow_dispatch:

jobs:
release_sda_admin:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Get version tag
run: |
VERSION=$(cat sda-admin/.version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create release
uses : softprops/action-gh-release@v2
with:
tag_name: "sda-admin-${{ env.VERSION }}"

package_sda_admin:
needs: [release_sda_admin]
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
# List of GOOS and GOARCH pairs from `go tool dist list`
goosarch:
- "linux/amd64"
- "windows/amd64"
- "darwin/amd64"
- "darwin/arm64"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.22'
id: go

- name: Get dependencies
run: |
cd sda-admin
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi

- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
VERSION=$(cat sda-admin/.version)
BINARY_NAME=sda-admin_${VERSION}_${GOOS}_${GOARCH}
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Build
if: ${{ matrix.goosarch != 'windows/amd64' }}
run: |
cd sda-admin
go build -o "$BINARY_NAME" -v -ldflags="-s -w -X 'main.version=$VERSION'"
tar -czf "$BINARY_NAME.tgz" "$BINARY_NAME" ../LICENSE
echo "ARTIFACT"="$BINARY_NAME.tgz" >> $GITHUB_ENV

- name: Build windows
if: ${{ matrix.goosarch == 'windows/amd64' }}
run: |
cd sda-admin
go build -o "$BINARY_NAME" -v -ldflags="-s -w -X 'main.version=$VERSION'"
zip "$BINARY_NAME.zip" "$BINARY_NAME" ../LICENSE
echo "ARTIFACT"="$BINARY_NAME.zip" >> $GITHUB_ENV

- name: Upload artifact
run: gh release upload "sda-admin-${{ env.VERSION }}" "sda-admin/${{ env.ARTIFACT }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions sda-admin/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
2 changes: 1 addition & 1 deletion sda-admin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/neicnordic/sensitive-data-archive/sda-admin/user"
)

var version = "1.0.0"
var version = "development"

var (
apiURI string
Expand Down
Loading