Skip to content

Commit

Permalink
finally
Browse files Browse the repository at this point in the history
  • Loading branch information
walteh committed May 25, 2024
1 parent d47d623 commit 2c2ffec
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 37 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/simver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@
with: { go-version: "${{ env.GO_VERSION }}" },
},
{
name: install dependencies,
name: download dependencies,
run: "cd __simver__ && go mod download",
},
{
name: install simver,
run: "cd __simver__ && go install ./cmd/simver_gha",
},
{
name: run simver,
env:
{
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}",
},
run: "go run ./__simver__/cmd/simver_gha --read-only=false",
run: "simver_gha --read-only=false",
},
] } },
}
80 changes: 45 additions & 35 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,48 @@ inputs: { GITHUB_TOKEN: { description: "GitHub token", required: true } }
runs:
using: "composite"
steps:
- name: checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: print git context
shell: bash
run: "jq . -r <<< '${{ toJson(github) }}' | tee /dev/stderr"
- name: get current action ref
id: get-action-ref
shell: bash
# the value we need is the suggix of the github.action_path variable after the "walteh/simver/" is found
run: "echo '${{ github.action_path }}' | sed -n 's/.*walteh\\/simver\\///p' | xargs -I {} echo 'SIMVER_GITHUB_ACTION_REF={}' >> $GITHUB_ENV"
- name: checkout simver code
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: walteh/simver
ref: ${{ env.SIMVER_GITHUB_ACTION_REF }}
path: "__simver__"
- name: get current go version from go.mod
id: go-version
shell: bash
run: 'cat __simver__/go.mod | grep ''go '' | awk ''{print $2}'' | xargs -I {} echo "GO_VERSION={}" >> $GITHUB_ENV'
- name: setup golang
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: install dependencies
shell: bash
run: "cd __simver__ && go mod download"
- name: install simver
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
run: "go run ./__simver__/cmd/simver_gha --read-only=false"
- name: checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: print git context
shell: bash
run: "jq . -r <<< '${{ toJson(github) }}' | tee /dev/stderr"

- name: get current action ref
id: get-action-ref
shell: bash
run: "echo '${{ github.action_path }}' | sed -n 's/.*walteh\\/simver\\///p' | xargs -I {} echo 'SIMVER_GITHUB_ACTION_REF={}' >> $GITHUB_ENV"

- name: checkout simver code
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: walteh/simver
ref: ${{ env.SIMVER_GITHUB_ACTION_REF }}
path: "__simver__"

- name: get current go version from go.mod
id: go-version
shell: bash
run: 'cat __simver__/go.mod | grep ''go '' | awk ''{print $2}'' | xargs -I {} echo "GO_VERSION={}" >> $GITHUB_ENV'

- name: setup golang
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: download dependencies
shell: bash
run: "cd __simver__ && go mod download"

- name: install simver
shell: bash
run: "cd __simver__ && go install ./cmd/simver_gha"

- name: run simver
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
run: "simver_gha --read-only=false"

0 comments on commit 2c2ffec

Please sign in to comment.