diff --git a/.github/workflows/alpha-release.yml b/.github/workflows/alpha-release.yml new file mode 100644 index 0000000..2eab805 --- /dev/null +++ b/.github/workflows/alpha-release.yml @@ -0,0 +1,58 @@ +name: Alpha Release +on: + workflow_dispatch: + inputs: + alpha: + description: "Alpha version (e.g. 1, 2, 3)" + required: true + +jobs: + get-tag: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.name }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get tag + id: tag + run: echo "name=$(cat internal/assets/version)-alpha.${{ github.event.inputs.alpha }}" >> $GITHUB_OUTPUT + + build-docker: + needs: get-tag + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + platforms: linux/arm64, linux/amd64 + tags: ghcr.io/${{ github.repository_owner }}/tinyauth:${{ needs.get-tag.outputs.tag }} + + alpha-release: + needs: [get-tag, build-docker] + runs-on: ubuntu-latest + steps: + - name: Create alpha release + uses: softprops/action-gh-release@v2 + with: + prerelease: true + tag_name: ${{ needs.get-tag.outputs.tag }} diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml new file mode 100644 index 0000000..99d44fc --- /dev/null +++ b/.github/workflows/beta-release.yml @@ -0,0 +1,58 @@ +name: Beta Release +on: + workflow_dispatch: + inputs: + alpha: + description: "Beta version (e.g. 1, 2, 3)" + required: true + +jobs: + get-tag: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.name }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get tag + id: tag + run: echo "name=$(cat internal/assets/version)-beta.${{ github.event.inputs.alpha }}" >> $GITHUB_OUTPUT + + build-docker: + needs: get-tag + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + platforms: linux/arm64, linux/amd64 + tags: ghcr.io/${{ github.repository_owner }}/tinyauth:${{ needs.get-tag.outputs.tag }} + + beta-release: + needs: [get-tag, build-docker] + runs-on: ubuntu-latest + steps: + - name: Create beta release + uses: softprops/action-gh-release@v2 + with: + prerelease: true + tag_name: ${{ needs.get-tag.outputs.tag }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a6071a4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: Release +on: + workflow_dispatch: + +jobs: + get-tag: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.name }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get tag + id: tag + run: echo "name=$(cat internal/assets/version)" >> $GITHUB_OUTPUT + + build-docker: + needs: get-tag + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + platforms: linux/arm64, linux/amd64 + tags: ghcr.io/${{ github.repository_owner }}/tinyauth:${{ needs.get-tag.outputs.tag }}, ghcr.io/${{ github.repository_owner }}/tinyauth:latest + + release: + needs: [get-tag, build-docker] + runs-on: ubuntu-latest + steps: + - name: Create release + uses: softprops/action-gh-release@v2 + with: + prerelease: false + make_latest: false + tag_name: ${{ needs.get-tag.outputs.tag }} diff --git a/cmd/root.go b/cmd/root.go index e2fd3c2..336db04 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -4,6 +4,7 @@ import ( "os" "time" "tinyauth/internal/api" + "tinyauth/internal/assets" "tinyauth/internal/types" "tinyauth/internal/utils" @@ -21,7 +22,7 @@ var rootCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // Logger log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}).With().Timestamp().Logger() - log.Info().Msg("Starting tinyauth") + log.Info().Str("version", assets.Version).Msg("Starting tinyauth") // Get config log.Info().Msg("Parsing config") diff --git a/internal/assets/VERSION b/internal/assets/VERSION new file mode 100644 index 0000000..9ff151c --- /dev/null +++ b/internal/assets/VERSION @@ -0,0 +1 @@ +v0.1.0 \ No newline at end of file diff --git a/internal/assets/assets.go b/internal/assets/assets.go index 6dbfd2a..88df1c7 100644 --- a/internal/assets/assets.go +++ b/internal/assets/assets.go @@ -5,4 +5,7 @@ import ( ) //go:embed dist -var Assets embed.FS \ No newline at end of file +var Assets embed.FS + +//go:embed VERSION +var Version string \ No newline at end of file