Skip to content

fix: account create errors #57

fix: account create errors

fix: account create errors #57

Workflow file for this run

name: Release with GoReleaser
on:
push:
branches: [main]
tags:
- "v*"
pull_request:
branches: [main]
permissions:
contents: write # For creating releases
packages: write # For pushing to GitHub Container Registry
issues: write # For creating and updating issues
jobs:
# First job to run unit tests
test:
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
check-latest: true
- name: Run unit tests
run: go test -p 1 $(go list ./... | grep -v /test/) -v
# Integration tests job
integration-test:
name: Run Integration Tests
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
check-latest: true
- name: Start MongoDB
run: |
docker run -d \
--name mongodb \
-p 27017:27017 \
mongo:7 \
mongod --replSet rs0
# Wait for MongoDB to be ready
timeout 30 bash -c 'until docker exec mongodb mongosh --eval "db.runCommand({ ping: 1 })" > /dev/null 2>&1; do sleep 1; done'
# Initialize replica set
docker exec mongodb mongosh --eval "rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27017' }] })"
# Wait for replica set to be ready
sleep 5
- name: Start MailHog
run: |
docker run -d \
--name mailhog \
-p 1025:1025 \
-p 8025:8025 \
mailhog/mailhog:latest
- name: Build bulwarkauth
run: go build -o bulwarkauth ./cmd/bulwarkauth
- name: Start bulwarkauth service
run: |
./bulwarkauth &
echo $! > bulwarkauth.pid
# Wait for service to be ready
timeout 30 bash -c 'until curl -f http://localhost:8080/health > /dev/null 2>&1; do sleep 1; done'
env:
DB_CONNECTION: mongodb://localhost:27017/?connect=direct
DB_NAME_SEED: spont
DOMAIN: latebit.io
WEBSITE_NAME: latebit
EMAIL_FROM_ADDRESS: admin@lateflip.io
ENABLE_SMTP: true
EMAIL_SMTP_HOST: localhost
EMAIL_SMTP_PORT: 1025
EMAIL_SMTP_AUTH: false
EMAIL_SMTP_SECURE: false
VERIFICATION_URL: https://localhost:1221/verify
FORGOT_PASSWORD_URL: https://localhost:3000/reset/password
MAGIC_URL: https://localhost:1221/authenticate
MAGIC_CODE_EXPIRE_IN_MINUTES: 10
ACCESS_TOKEN_EXPIRE_IN_SECONDS: 3600
REFRESH_TOKEN_EXPIRE_IN_SECONDS: 9600
PORT: 8080
TEST_MODE: true
API_KEY_ENABLE: false
CORS_ENABLED: false
LOCKOUT_DURATION_IN_SEC: 2
- name: Run integration tests
run: go test -v ./...
working-directory: test
- name: Stop bulwarkauth service
if: always()
run: |
if [ -f bulwarkauth.pid ]; then
kill $(cat bulwarkauth.pid) || true
fi
- name: Cleanup containers
if: always()
run: |
docker stop mongodb mailhog || true
docker rm mongodb mailhog || true
# Second job to determine the next version
semver:
name: Calculate Semantic Version
needs: [test, integration-test]
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.semantic-version.outputs.version }}
new_tag: ${{ steps.semantic-version.outputs.version_tag }}
should_release: ${{ steps.release-check.outputs.should_release }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Semantic versioning
id: semantic-version
uses: PaulHatch/semantic-version@v5.3.0
with:
tag_prefix: "v"
major_pattern: "BREAKING CHANGE:"
minor_pattern: "feat:"
patch_pattern: "fix:"
format: "${major}.${minor}.${patch}"
bump_each_commit: false
search_commit_body: true
- name: Check if this is a release
id: release-check
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" && "${{ github.ref }}" == refs/tags/v* ]]; then
echo "should_release=true" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "should_release=true" >> $GITHUB_OUTPUT
else
echo "should_release=false" >> $GITHUB_OUTPUT
fi
- name: Debug version info
run: |
echo "New version: ${{ steps.semantic-version.outputs.version }}"
echo "New tag: v${{ steps.semantic-version.outputs.version }}"
echo "Should release: ${{ steps.release-check.outputs.should_release }}"
create-tag:
name: Create Git Tag
needs: semver
if: needs.semver.outputs.should_release == 'true' && github.ref_type != 'tag'
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag-info.outputs.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create GitHub tag
id: create-tag
uses: actions/github-script@v7
with:
script: |
const tagName = 'v${{ needs.semver.outputs.new_version }}';
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tagName}`,
sha: context.sha
});
console.log(`Created tag: ${tagName}`);
return tagName;
} catch (error) {
console.log(`Failed to create tag: ${error.message}`);
return '';
}
- name: Set tag info
id: tag-info
run: |
echo "tag_name=v${{ needs.semver.outputs.new_version }}" >> $GITHUB_OUTPUT
# Second job to build and publish with GoReleaser
release:
name: Release with GoReleaser
needs: [semver, create-tag]
if: needs.semver.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
check-latest: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate release tag
if: github.ref_type != 'tag'
run: |
echo "RELEASE_TAG=v${{ needs.semver.outputs.new_version }}" >> $GITHUB_ENV
- name: Use existing tag
if: github.ref_type == 'tag'
run: |
echo "RELEASE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Debug GitHub context
run: |
echo "github.ref: ${{ github.ref }}"
echo "github.ref_type: ${{ github.ref_type }}"
echo "github.ref_name: ${{ github.ref_name }}"
echo "startsWith condition: ${{ startsWith(github.ref, 'refs/tags/v') }}"
echo "github.event_name: ${{ github.event_name }}"
echo "github.event.ref: ${{ github.event.ref }}"
- name: Run GoReleaser (release)
# if: startsWith(github.ref, 'refs/tags/v')
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ env.RELEASE_TAG }}
# - name: Run GoReleaser (snapshot)
# if: "!startsWith(github.ref, 'refs/tags/v')"
# uses: goreleaser/goreleaser-action@v5
# with:
# distribution: goreleaser
# version: latest
# args: release --snapshot --clean
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GORELEASER_CURRENT_TAG: ${{ env.RELEASE_TAG }}