diff --git a/.github/actions/create-tag-and-github-release/action.yml b/.github/actions/create-tag-and-github-release/action.yml new file mode 100644 index 0000000000..97bf026b7c --- /dev/null +++ b/.github/actions/create-tag-and-github-release/action.yml @@ -0,0 +1,51 @@ +name: Tag Repository and Create GitHub Release +description: Tags the repository and creates a GitHub release +inputs: + prerelease: + description: "Whether the release is a prerelease" + required: false + type: boolean + default: true + GH_TOKEN: + description: "GitHub token" + required: true + type: string +outputs: + tag: + description: "Tag that has been added" + value: ${{ steps.compute-tag.outputs.tag }} +runs: + using: "composite" + steps: + - run: | + git config --global user.name "Dax the Duck" + git config --global user.email "dax@duckduckgo.com" + shell: bash + + - id: compute-tag + run: | + version="$(cut -d ' ' -f 3 < Configuration/Version.xcconfig)" + if [[ "${{ inputs.prerelease }}" == "true" ]]; then + build_number="$(cut -d ' ' -f 3 < Configuration/BuildNumber.xcconfig)" + tag="${version}-${build_number}" + else + tag="${version}" + fi + echo "tag=${tag}" >> $GITHUB_OUTPUT + shell: bash + + - id: tag-repo + run: | + git tag ${{ steps.compute-tag.outputs.tag }} + git push origin ${{ steps.compute-tag.outputs.tag }} + shell: bash + + - id: create-github-release + run: | + latest_release="$(gh api /repos/${{ github.repository }}/releases/latest --jq '.tag_name')" + if [[ "${{ inputs.prerelease }}" == "true" ]]; then + gh release create ${{ steps.compute-tag.outcome.tag }} --generate-notes --prerelease --notes-start-tag ${latest_release} + else + gh release create ${{ steps.compute-tag.outcome.tag }} --generate-notes --notes-start-tag ${latest_release} + fi + shell: bash diff --git a/.github/workflows/tag_and_merge.yml b/.github/workflows/tag_and_merge.yml index 5d6467b65b..eb1db66d3b 100644 --- a/.github/workflows/tag_and_merge.yml +++ b/.github/workflows/tag_and_merge.yml @@ -70,23 +70,11 @@ jobs: access-token: ${{ secrets.ASANA_ACCESS_TOKEN }} task-id: ${{ steps.get-task-id.outputs.task-id }} - - name: Set up git - run: | - git config --global user.name "Dax the Duck" - git config --global user.email "dax@duckduckgo.com" - - - name: Construct a tag - id: construct-tag - run: | - version="$(cut -d ' ' -f 3 < Configuration/Version.xcconfig)" - build_number="$(cut -d ' ' -f 3 < Configuration/BuildNumber.xcconfig)" - tag="${version}-${build_number}" - echo "tag=${tag}" >> $GITHUB_OUTPUT - - - name: Tag the repo - run: | - git tag ${{ steps.construct-tag.outputs.tag }} - git push origin ${{ steps.construct-tag.outputs.tag }} + - name: Create Tag and GitHub Release + uses: ./.github/actions/create-tag-and-github-release + with: + prerelease: true + GH_TOKEN: ${{ github.token }} - name: Merge to base branch id: merge