Merge pull request #7 from sharathrnair87/feature/use_vault_go_sdk #40
Workflow file for this run
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
name: Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
permissions: | |
contents: write | |
actions: write | |
jobs: | |
update_version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
ref: main | |
path: './' | |
- name: Set up Git | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "actions@buungroup.com" | |
git remote set-url origin https://github.com/DFW1N/vaultify.git | |
git fetch | |
- name: Get latest tag | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0) | |
echo "Latest Tag: $latest_tag" | |
echo "::set-output name=latest_tag::$latest_tag" | |
- name: Update version in version.go | |
run: | | |
latest_tag="$(git describe --tags --abbrev=0)" | |
sed -i "s/const version = .*/const version = \"$latest_tag\"/" cmd/version.go | |
echo "Updated cmd/version.go with version $latest_tag" | |
- name: Check for changes and commit | |
run: | | |
if git diff --quiet; then | |
echo "No changes to commit. Continuing." | |
else | |
git add cmd/version.go | |
git commit -m "Update version to $latest_tag for the release workflow" | |
git push origin main | |
fi | |
go-tests: | |
needs: update_version | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
ref: main | |
path: './' | |
- name: Set up Go | |
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Run Go Tests | |
run: go test -v ./tests -coverprofile=coverage.out | |
continue-on-error: false | |
- name: Check for Test Failures | |
if: failure() | |
run: echo "Tests failed. Check the logs for more details." | |
- name: Test Coverage | |
run: go tool cover -func=coverage.out | |
continue-on-error: false | |
build: | |
needs: go-tests | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
ref: main | |
path: './' | |
- run: git fetch --force --tags | |
- name: Debug Tags | |
run: | | |
git fetch --tags | |
git tag -l | |
- name: Set up Go | |
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
# - name: Build | |
# run: CGO_ENABLED=0 go build -o vaultify -a -ldflags '-extldflags "-static"' | |
- name: build | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549 | |
id: import_gpg | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Sign binaries | |
run: | | |
find dist -type f -name 'vaultify' -exec gpg --armor --detach-sign -o {}.sig {} \; | |
env: | |
GPG_TTY: /dev/tty | |
# - name: Create Release | |
# id: create_release | |
# uses: softprops/action-gh-release@v1 | |
# with: | |
# files: | | |
# vaultify | |
# vaultify.sig | |
# body: "Release notes here" | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# SIGNATURE_KEY: ${{ secrets.GPG_PASSPHRASE }} | |
docker-build-publish: | |
needs: build | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push Docker Image | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0) | |
echo "Latest Tag: $latest_tag" | |
modified_tag="${latest_tag#v}" | |
echo "Modified Tag: $modified_tag" | |
cd docker | |
ls -al | |
docker build -t buungroup/vault-raft:$modified_tag . -f Dockerfile | |
docker push buungroup/vault-raft:$modified_tag |