check git version #53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI_package | |
on: | |
push: | |
branches: | |
- 'dummy_main' | |
- 'dummy_main_PR_test' | |
tags: | |
- '*' | |
jobs: | |
tag-version: | |
if: github.ref_type != 'tag' | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout ${{ github.head_ref }} | |
uses: actions/checkout@v4 | |
- name: check git | |
shell: bash | |
run: | | |
git version | |
git log --help | grep "%P" -C 5 | |
- name: temporize | |
shell: bash | |
run: | | |
git log -n 1 | |
git log -n 1 --parents | |
- name: temporize 2 | |
shell: bash | |
run: | | |
git log -n 1 | |
git log -n 1 --parents | |
- name: quit branch for detached head | |
shell: bash | |
run: | | |
git checkout cb5445b | |
- name: check | |
shell: bash | |
run: | | |
git log -n 1 | |
git log -n 1 --parents | |
- name: compute tag name | |
shell: bash | |
run: | | |
git log --pretty="%h" -n 1 | |
git log -n 1 | |
git log -n 2 | |
git log -n 2 --parents | |
git log --pretty=%P -1 --merges | |
git log --pretty=%P -1 --no-merges | |
git log --pretty="%p" -n 1 | |
git log -n 1 --pretty="%P" | |
git log -n 1 --pretty="%p" | |
git log -n 1 --pretty=%p | |
git log --pretty="%p" -n 1 | |
echo $([[ $(git log --pretty="%p" -n 1 | wc -w) -gt 1 ]] && echo "PR 1" || echo "regular push 1") | |
echo $([[ $(git log --pretty="%p" -n 1 | wc -w) -gt 1 ]] \ | |
&& echo "PR" \ | |
|| echo "regular push") | |
branch=$([[ $(git log --pretty="%p" -n 1 | wc -w) -gt 1 ]] \ | |
&& echo $(git log -n 1 --pretty="%s" | sed "s|.*Geoportail-Luxembourg/\(.*\)|\1|") \ | |
|| git branch --show-current) | |
echo branch | |
echo "AUTO_TAG=${branch}_CI_$(git log -n 1 --pretty=%h)" >> $GITHUB_ENV | |
- name: tag ${{ github.head_ref }} | |
run: | | |
git tag ${{ env.AUTO_TAG }} | |
git push --tags | |
lux-package: | |
# the combination (if always) + (needs tag-version) makes sure the lux-package job runs | |
# after completion of the tag-version job. | |
# In case of a tag push, the tag-version job is skipped but the lux-package job will run | |
# In case of a closed PR, the tag-version job runs first, the lux-package job runs after completion | |
if: github.ref == 'no_skip' | |
# if: ${{ always() }} | |
needs: tag-version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: compute tag name | |
shell: bash | |
run: | | |
at=$(git rev-parse --abbrev-ref HEAD)_CI_$(git rev-parse --short HEAD) | |
echo "AUTO_TAG=$at" >> $GITHUB_ENV | |
- name: create release | |
id: create_release | |
uses: octokit/request-action@v2.x | |
with: | |
# secrets.GITHUB_TOKEN is a secret only valid for one CI execution | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
route: POST /repos/{owner}/{repo}/releases | |
owner: 'Geoportail-Luxembourg' | |
repo: 'luxembourg-geoportail' | |
tag_name: ${{ github.event_name == 'push' && github.ref || env.AUTO_TAG }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: 'npm' | |
- name: Build and pack prod library | |
shell: bash | |
run: | | |
npm ci | |
npm run build:lib:prod | |
npm pack | |
- name: upload manually | |
run: | | |
project_name=$(npm run env | grep "npm_package_name" | sed s/npm_package_name=//) | |
pkg_name=$(ls $project_name-*) | |
lib_name=$(echo $pkg_name | sed s/luxembourg-geoportail-/luxembourg-geoportail-lib-/) | |
curl -X POST "https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$lib_name" --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/octet-stream" --data-binary "@$pkg_name" | |
env: | |
owner: 'Geoportail-Luxembourg' | |
repo: 'luxembourg-geoportail' | |
id: ${{ fromJSON(steps.create_release.outputs.data).id }} |