diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0a498e..2fb6760 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,16 @@ name: Release Next Version on: - push: - branches: [ "main" ] - + workflow_dispatch: + inputs: + release_tag: + description: 'Release Tag' + required: true + type: string +env: + NEW_VERSION: ${{ github.event.inputs.release_tag }} jobs: - release: - if: ${{ startsWith(github.event.head_commit.message, 'release:') }} + release-pr: runs-on: ubuntu-latest - env: - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} permissions: contents: write steps: @@ -17,26 +19,32 @@ jobs: ref: main fetch-depth: 0 token: ${{ secrets.PROJECT_TOKEN }} - - name: Create new tag - run: | - echo "${{ env.COMMIT_MESSAGE }}" - version=$(echo "${{ env.COMMIT_MESSAGE }}" | grep -oP 'Android \K\d+\.\d+\.\d+') - echo "release_version=$version" >> "$GITHUB_ENV" - echo $version - git config user.name '${{ vars.USER_NAME }}' - git config user.email '${{ vars.USER_EMAIL }}' - git tag v$version - git push origin v$version - - name: Assemble release + - name: Modify for next release run: | - chmod +x gradlew - ./gradlew assembleRelease - - name: Create GitHub release - uses: softprops/action-gh-release@v1 - with: - name: "Clickstream Android $release_version" - files: | - clickstream/build/outputs/aar/clickstream-release.aar - tag_name: "v$release_version" - prerelease: true - generate_release_notes: true \ No newline at end of file + chmod +x release.sh + ./release.sh ${{ env.NEW_VERSION }} + git diff + git config user.name "github-actions" + git config user.email "github-actions@github.com" + - name: Create Pull Request + id: create-pr + uses: peter-evans/create-pull-request@v5 + token: ${{ secrets.PROJECT_TOKEN }} + commit-message: 'release: clickstream Android ${{ env.NEW_VERSION }}' + title: 'release: clickstream Android ${{ env.NEW_VERSION }}' + author: github-actions + committer: github-actions + signoff: true + body: | + - [x] PR title and description conform to [Pull Request](https://github.com/awslabs/clickstream-android/blob/main/CONTRIBUTING.md#pull-request-guidelines) guidelines. + + *Description of changes:* + 1. 'release: clickstream Android ${{ env.NEW_VERSION }}' + + *Documentation update required?* + - [ ] No + - [x] Yes (Please include a PR link for the documentation update) + + By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. + labels: release + branch: release_${{ env.NEW_VERSION }} \ No newline at end of file diff --git a/.github/workflows/release_pr.yml b/.github/workflows/release_pr.yml deleted file mode 100644 index e0461ed..0000000 --- a/.github/workflows/release_pr.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Create Release PR -on: - workflow_dispatch: - inputs: - release_tag: - description: 'Release Tag' - required: true - type: string -env: - NEW_VERSION: ${{ github.event.inputs.release_tag }} -jobs: - release-pr: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - with: - ref: main - fetch-depth: 0 - token: ${{ secrets.PROJECT_TOKEN }} - - name: Modify for next release - run: | - chmod +x release.sh - ./release.sh ${{ env.NEW_VERSION }} - git diff - git config user.name "github-actions" - git config user.email "github-actions@github.com" - - name: Create Pull Request - id: create-pr - uses: peter-evans/create-pull-request@v5 - token: ${{ secrets.PROJECT_TOKEN }} - commit-message: 'release: clickstream Android ${{ env.NEW_VERSION }}' - title: 'release: clickstream Android ${{ env.NEW_VERSION }}' - author: github-actions - committer: github-actions - signoff: true - body: | - - [x] PR title and description conform to [Pull Request](https://github.com/awslabs/clickstream-android/blob/main/CONTRIBUTING.md#pull-request-guidelines) guidelines. - - *Description of changes:* - 1. 'release: clickstream Android ${{ env.NEW_VERSION }}' - - *Documentation update required?* - - [ ] No - - [x] Yes (Please include a PR link for the documentation update) - - By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. - labels: release - branch: release_${{ env.NEW_VERSION }} \ No newline at end of file diff --git a/.github/workflows/tag_and_release.yml b/.github/workflows/tag_and_release.yml new file mode 100644 index 0000000..73f033b --- /dev/null +++ b/.github/workflows/tag_and_release.yml @@ -0,0 +1,42 @@ +name: Create Tag And Release +on: + push: + branches: [ "main" ] + +jobs: + release: + if: ${{ startsWith(github.event.head_commit.message, 'release:') }} + runs-on: ubuntu-latest + env: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + ref: main + fetch-depth: 0 + token: ${{ secrets.PROJECT_TOKEN }} + - name: Create new tag + run: | + echo "${{ env.COMMIT_MESSAGE }}" + version=$(echo "${{ env.COMMIT_MESSAGE }}" | grep -oP 'Android \K\d+\.\d+\.\d+') + echo "release_version=$version" >> "$GITHUB_ENV" + echo $version + git config user.name '${{ vars.USER_NAME }}' + git config user.email '${{ vars.USER_EMAIL }}' + git tag v$version + git push origin v$version + - name: Assemble release + run: | + chmod +x gradlew + ./gradlew assembleRelease + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + name: "Clickstream Android $release_version" + files: | + clickstream/build/outputs/aar/clickstream-release.aar + tag_name: "v$release_version" + prerelease: true + generate_release_notes: true \ No newline at end of file