diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0e525a..1f07bb3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6 with: - go-version-file: 'go.mod' + go-version-file: go.mod - name: Storage-CLI Build for Linux env: @@ -53,4 +53,4 @@ jobs: path: | storage-cli-linux-amd64 storage-cli-windows-amd64.exe - retention-days: 30 + retention-days: 30 \ No newline at end of file diff --git a/.github/workflows/release-auto.yml b/.github/workflows/release-auto.yml new file mode 100644 index 0000000..ca42eab --- /dev/null +++ b/.github/workflows/release-auto.yml @@ -0,0 +1,134 @@ +name : Release Auto + +on: + push: + branches: [ main ] + workflow_dispatch: + inputs: + version_bump: + description: 'version bump type' + required: false + default: patch + type: choice + options: + - patch + - minor + - major + +jobs: + tests: + name: Run Unit Tests + runs-on: [ubuntu-latest] + steps: + - name: Checkout Into Source Code + uses: actions/checkout@v5 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Lint code + uses: golangci/golangci-lint-action@v8 + + - name: Run Unit Tests + run: | + export CGO_ENABLED=0 + go version + go run github.com/onsi/ginkgo/v2/ginkgo --skip-package=integration ./... + + build-and-release: + name: Build and Release + needs: tests + runs-on: ubuntu-latest + steps: + - name: Checkout Into Source Code + uses: actions/checkout@v5 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Bump Version and Create Tag + id: tag_version + uses: anothrNick/github-tag-action@1.70.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # DEFAULT_BUMP is used when there are no MAJOR_STRING_TOKEN or MINOR_STRING_TOKEN, + # or for manual workflow_dispatch + DEFAULT_BUMP: ${{ github.event.inputs.version_bump || 'patch'}} + WITH_V: true + MAJOR_STRING_TOKEN: "BREAKING CHANGE:" + MINOR_STRING_TOKEN: "feat:" + PRERELEASE: false + + - name: Export Version Variable + run: | + VERSION=${{steps.tag_version.outputs.new_tag}} + VERSION_NUMBER=${VERSION#v} + echo "VERSION_NUMBER=${VERSION_NUMBER}" >> $GITHUB_ENV + + - name: Generate Changelog + id: changelog + uses: mikepenz/release-changelog-builder-action@v5 + with: + toTag: ${{ steps.tag_version.outputs.new_tag }} + commitMode: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build for Linux + env: + GOOS: linux + GOARCH: amd64 + CGO_ENABLED: 0 + VERSION: ${{ steps.tag_version.outputs.new_tag}} + run: | + echo "Building Storage CLI for Linux" + go build -ldflags "-X main.version=${{ env.VERSION_NUMBER }}" \ + -o "storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64" + echo "### Linux Build Checksums" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + sha1sum "storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + - name: Build for Windows + env: + GOOS: windows + GOARCH: amd64 + CGO_ENABLED: 0 + VERSION: ${{ steps.tag_version.outputs.new_tag }} + run: | + echo "Building Storage CLI for Windows" + go build -ldflags "-X main.version=${{ env.VERSION_NUMBER }}" \ + -o "storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe" + echo "### Windows Build Checksums" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + sha1sum "storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + - name: Create Github Release + uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.tag_version.outputs.new_tag }} + name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.changelog.outputs.changelog }} + artifacts: | + storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64 + storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe + token: ${{ secrets.GITHUB_TOKEN }} + + # - name: Configure AWS + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # aws-region: us-east-1 + + # - name: Upload Artifacts to S3 + # run: | + # aws s3 cp "storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64" \ + # "s3://storage-cli-artifacts/storage-cli-${{ env.VERSION_NUMBER }}-linux-amd64" + # aws s3 cp "storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe" \ + # "s3://storage-cli-artifacts/storage-cli-${{ env.VERSION_NUMBER }}-windows-amd64.exe" \ No newline at end of file diff --git a/README.md b/README.md index 19f51dd..b48ef47 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ Follow these steps to make a contribution to the project: ``` - If you added or modified integration tests, to run them locally, follow the instructions in the provider-specific README (see [Providers](#providers) section) - Push changes to your fork +- **IMPORTANT:** Before writing commit message check [release section](#automated-release-process) and [commit message examples](#commit-message-examples) ``` bash git add . git commit -m "Commit message" @@ -132,6 +133,44 @@ Option 2: Release via Draft Release - The release will appear immediately on the Releases page. This action will also trigger the *Release Manual* workflow, which will build the artifacts and upload them to the published release once the workflow finishes. +### Automated Release + +When changes are merged into the `main` branch, a new release is automatically triggered. The version number is determined using **semantic versioning** based on conventional commit message prefixes: + +**Version Bump Rules:** +- `feat:` - New feature → **Minor version bump** (v1.2.0 → v1.3.0) +- `BREAKING CHANGE:` - Breaking changes → **Major version bump** (v1.2.0 → v2.0.0) +- Patch version bump (v1.2.0 → v1.2.1) + - `fix:` - Bug fix + - `docs:` - Documentation changes + - `chore:` - Maintenance tasks (dependencies, build config, tooling) + - `refactor:` - Code restructuring without behavior changes + - `test:` - Test updates + - `style:` - Formatting and whitespace + - `ci:` - CI/CD configuration changes + - `perf:` - Performance improvements + - `build:` - Dependabot commits + - `no conventional commits` - text without specifying any of above + +**Note: When the repo becomes more stable, we are gonna merge these 2 release logic.** + +#### Commit Message Examples + +```bash +# Major release (v1.2.3 → v2.0.0) +git commit -m "feat: redesign upload API + +BREAKING CHANGE: Upload() signature changed to return structured error" + +# Minor release (v1.2.3 → v1.3.0) +git commit -m "feat: add retry logic for failed uploads" + +# Patch release (v1.2.3 → v1.2.4) +git commit -m "docs: update Azure Blob Storage usage examples" +git commit -m "chore: upgrade dependencies" +git commit -m "class x moved to another folder" +``` + ## Notes These commit IDs represent the last migration checkpoint from each provider's original repository, marking the final commit that was copied during the consolidation process.