Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not tagging the last commit #37

Open
edouard-lopez opened this issue Dec 14, 2022 · 1 comment
Open

Not tagging the last commit #37

edouard-lopez opened this issue Dec 14, 2022 · 1 comment

Comments

@edouard-lopez
Copy link

Goal

Working on pure-fish I aim to have a workflow that does:

  1. create a bump commit using thenativeweb/get-next-version action then push said commit to master
  2. checkout master and use autotag

Expectation

* cda6090 (HEAD -> master, tag: v4.4.0) chore: bump version 4.4.0
* 5c4af3a ci(version): tag on push on master and on PR merge
* bedae60 chore(lint): re-format

Actual

The tag is placed on the previous commit

* cda6090 (HEAD -> master) chore: bump version 4.4.0
* 5c4af3a (tag: v4.4.0) ci(version): tag on push on master and on PR merge
* bedae60 chore(lint): re-format

image

Workflow

name: Add New Tag After Merge

on:
  workflow_call: # allow this workflow to be called from other workflows

jobs:
  bump-version:
    # if: github.event_name == 'push' || github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Get next version
        id: next_version
        uses: thenativeweb/get-next-version@main

      - name: Show the next version
        run: |
          echo ${{ steps.next_version.outputs.version }}
          echo ${{ steps.next_version.outputs.hasNextVersion }}

      - name: Bump version file
        if: steps.next_version.outputs.hasNextVersion == 'true'
        run: |
          perl -i -p -e \
            "s/(pure_version)\s(\d+(\.)?){3}/\1 ${{ steps.next_version.outputs.version }}/" \
            ./conf.d/pure.fish

      - name: Set git user metadata
        if: steps.next_version.outputs.hasNextVersion == 'true'
        run: |
          git config user.name github-actions
          git config user.email [email protected]

      - name: Commit new version file
        if: steps.next_version.outputs.hasNextVersion == 'true'
        run: |
          git add --verbose ./conf.d/pure.fish \
          && git commit --allow-empty --message "chore: bump version ${{ steps.next_version.outputs.version }}" \
          && git push

  add-version-tag:
    # if: github.event_name == 'push' || github.event.pull_request.merged == true
    needs: [bump-version]
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v3
        with:
          ref: "master"

      - uses: butlerlogic/action-autotag@stable
        with:
          root: "./conf.d/pure.fish"
          regex_pattern: "pure_version\\s(?<version>(\\d+(\\.)?){3})"
          tag_prefix: "v"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Question

How can I tag the latest commit?

@edouard-lopez
Copy link
Author

Look like you are using GITHUB_SHA environment variable

object: process.env.GITHUB_SHA,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant