trying out entire action
This commit is contained in:
@@ -4,17 +4,16 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
# paths:
|
paths:
|
||||||
# - github-action/package.json
|
- github-action/package.json
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
verify_action:
|
||||||
test:
|
name: Verify action
|
||||||
name: Test action
|
runs-on: linux
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -32,194 +31,170 @@ jobs:
|
|||||||
working-directory: github-action
|
working-directory: github-action
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Run action tests
|
- name: Create verification fixture
|
||||||
working-directory: github-action
|
shell: bash
|
||||||
run: npm test
|
run: |
|
||||||
|
mkdir -p test-action-input
|
||||||
|
cat <<'EOF' > test-action-input/main.lua
|
||||||
|
local message = {}
|
||||||
|
|
||||||
# verify_action:
|
message.hello = function()
|
||||||
# name: Verify action
|
return "hello"
|
||||||
# runs-on: linux
|
end
|
||||||
# steps:
|
|
||||||
# - name: Checkout repository
|
|
||||||
# uses: actions/checkout@v4
|
|
||||||
# with:
|
|
||||||
# fetch-depth: 0
|
|
||||||
|
|
||||||
# - name: Set up Node.js
|
return message
|
||||||
# uses: actions/setup-node@v4
|
EOF
|
||||||
# with:
|
|
||||||
# node-version: 22
|
|
||||||
# cache: npm
|
|
||||||
# cache-dependency-path: github-action/package-lock.json
|
|
||||||
|
|
||||||
# - name: Install action dependencies
|
- name: Run action locally
|
||||||
# working-directory: github-action
|
uses: ./github-action
|
||||||
# run: npm ci
|
with:
|
||||||
|
source-root: test-action-input
|
||||||
|
output-file: test-action-output/compiled.lua
|
||||||
|
|
||||||
# - name: Create verification fixture
|
- name: Assert compiled output exists
|
||||||
# shell: bash
|
shell: bash
|
||||||
# run: |
|
run: test -f test-action-output/compiled.lua
|
||||||
# mkdir -p test-action-input
|
|
||||||
# cat <<'EOF' > test-action-input/main.lua
|
|
||||||
# local message = {}
|
|
||||||
|
|
||||||
# message.hello = function()
|
derive_release:
|
||||||
# return "hello"
|
name: Derive release metadata
|
||||||
# end
|
runs-on: linux
|
||||||
|
needs: verify_action
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.derive.outputs.version }}
|
||||||
|
release_tag: ${{ steps.derive.outputs.release_tag }}
|
||||||
|
rolling_minor_tag: ${{ steps.derive.outputs.rolling_minor_tag }}
|
||||||
|
rolling_major_tag: ${{ steps.derive.outputs.rolling_major_tag }}
|
||||||
|
bump_kind: ${{ steps.derive.outputs.bump_kind }}
|
||||||
|
should_publish: ${{ steps.derive.outputs.should_publish }}
|
||||||
|
latest_release_tag: ${{ steps.derive.outputs.latest_release_tag }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
# return message
|
- name: Derive version and tags
|
||||||
# EOF
|
id: derive
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
# - name: Run action locally
|
version=$(node -p "require('./github-action/package.json').version")
|
||||||
# uses: ./github-action
|
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
# with:
|
echo "github-action/package.json version must be semver X.Y.Z, got: $version" >&2
|
||||||
# source-root: test-action-input
|
exit 1
|
||||||
# output-file: test-action-output/compiled.lua
|
fi
|
||||||
|
|
||||||
# - name: Assert compiled output exists
|
IFS='.' read -r major minor patch <<< "$version"
|
||||||
# shell: bash
|
release_tag="action/v${version}"
|
||||||
# run: test -f test-action-output/compiled.lua
|
rolling_minor_tag="action/v${major}.${minor}"
|
||||||
|
rolling_major_tag="action/v${major}"
|
||||||
|
|
||||||
# derive_release:
|
latest_release_tag=$(git tag --list 'action/v*.*.*' --sort=-version:refname | head -n 1)
|
||||||
# name: Derive release metadata
|
|
||||||
# runs-on: linux
|
|
||||||
# needs: verify_action
|
|
||||||
# outputs:
|
|
||||||
# version: ${{ steps.derive.outputs.version }}
|
|
||||||
# release_tag: ${{ steps.derive.outputs.release_tag }}
|
|
||||||
# rolling_minor_tag: ${{ steps.derive.outputs.rolling_minor_tag }}
|
|
||||||
# rolling_major_tag: ${{ steps.derive.outputs.rolling_major_tag }}
|
|
||||||
# bump_kind: ${{ steps.derive.outputs.bump_kind }}
|
|
||||||
# should_publish: ${{ steps.derive.outputs.should_publish }}
|
|
||||||
# latest_release_tag: ${{ steps.derive.outputs.latest_release_tag }}
|
|
||||||
# steps:
|
|
||||||
# - name: Checkout repository
|
|
||||||
# uses: actions/checkout@v4
|
|
||||||
# with:
|
|
||||||
# fetch-depth: 0
|
|
||||||
|
|
||||||
# - name: Derive version and tags
|
bump_kind="initial"
|
||||||
# id: derive
|
should_publish="true"
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# set -euo pipefail
|
|
||||||
|
|
||||||
# version=$(node -p "require('./github-action/package.json').version")
|
if [[ -n "$latest_release_tag" ]]; then
|
||||||
# if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
latest_version=${latest_release_tag#action/v}
|
||||||
# echo "github-action/package.json version must be semver X.Y.Z, got: $version" >&2
|
|
||||||
# exit 1
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# IFS='.' read -r major minor patch <<< "$version"
|
if [[ "$version" == "$latest_version" ]]; then
|
||||||
# release_tag="action/v${version}"
|
should_publish="false"
|
||||||
# rolling_minor_tag="action/v${major}.${minor}"
|
bump_kind="duplicate"
|
||||||
# rolling_major_tag="action/v${major}"
|
else
|
||||||
|
IFS='.' read -r latest_major latest_minor latest_patch <<< "$latest_version"
|
||||||
|
|
||||||
# latest_release_tag=$(git tag --list 'action/v*.*.*' --sort=-version:refname | head -n 1)
|
if (( major < latest_major )) || \
|
||||||
|
(( major == latest_major && minor < latest_minor )) || \
|
||||||
|
(( major == latest_major && minor == latest_minor && patch < latest_patch )); then
|
||||||
|
echo "github-action/package.json version $version must be greater than latest published $latest_version" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# bump_kind="initial"
|
if (( major > latest_major )); then
|
||||||
# should_publish="true"
|
bump_kind="major"
|
||||||
|
elif (( minor > latest_minor )); then
|
||||||
|
bump_kind="minor"
|
||||||
|
elif (( patch > latest_patch )); then
|
||||||
|
bump_kind="patch"
|
||||||
|
else
|
||||||
|
echo "Unable to derive release kind from $latest_version -> $version" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# if [[ -n "$latest_release_tag" ]]; then
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||||
# latest_version=${latest_release_tag#action/v}
|
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "rolling_minor_tag=$rolling_minor_tag" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "rolling_major_tag=$rolling_major_tag" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "bump_kind=$bump_kind" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "should_publish=$should_publish" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "latest_release_tag=$latest_release_tag" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# if [[ "$version" == "$latest_version" ]]; then
|
- name: Summarize release plan
|
||||||
# should_publish="false"
|
shell: bash
|
||||||
# bump_kind="duplicate"
|
run: |
|
||||||
# else
|
{
|
||||||
# IFS='.' read -r latest_major latest_minor latest_patch <<< "$latest_version"
|
echo "## Action release plan"
|
||||||
|
echo ""
|
||||||
|
echo "- Version: ${{ steps.derive.outputs.version }}"
|
||||||
|
echo "- Release tag: ${{ steps.derive.outputs.release_tag }}"
|
||||||
|
echo "- Rolling minor tag: ${{ steps.derive.outputs.rolling_minor_tag }}"
|
||||||
|
echo "- Rolling major tag: ${{ steps.derive.outputs.rolling_major_tag }}"
|
||||||
|
echo "- Bump kind: ${{ steps.derive.outputs.bump_kind }}"
|
||||||
|
echo "- Latest published tag: ${{ steps.derive.outputs.latest_release_tag || 'none' }}"
|
||||||
|
echo "- Will publish: ${{ steps.derive.outputs.should_publish }}"
|
||||||
|
} >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
# if (( major < latest_major )) || \
|
publish_tags:
|
||||||
# (( major == latest_major && minor < latest_minor )) || \
|
name: Publish tags
|
||||||
# (( major == latest_major && minor == latest_minor && patch < latest_patch )); then
|
runs-on: linux
|
||||||
# echo "github-action/package.json version $version must be greater than latest published $latest_version" >&2
|
needs: derive_release
|
||||||
# exit 1
|
if: ${{ needs.derive_release.outputs.should_publish == 'true' }}
|
||||||
# fi
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
# if (( major > latest_major )); then
|
- name: Create immutable release tag
|
||||||
# bump_kind="major"
|
shell: bash
|
||||||
# elif (( minor > latest_minor )); then
|
run: |
|
||||||
# bump_kind="minor"
|
set -euo pipefail
|
||||||
# elif (( patch > latest_patch )); then
|
release_tag='${{ needs.derive_release.outputs.release_tag }}'
|
||||||
# bump_kind="patch"
|
|
||||||
# else
|
|
||||||
# echo "Unable to derive release kind from $latest_version -> $version" >&2
|
|
||||||
# exit 1
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# echo "version=$version" >> "$GITHUB_OUTPUT"
|
if git rev-parse "$release_tag" >/dev/null 2>&1; then
|
||||||
# echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
|
echo "Release tag $release_tag already exists" >&2
|
||||||
# echo "rolling_minor_tag=$rolling_minor_tag" >> "$GITHUB_OUTPUT"
|
exit 1
|
||||||
# echo "rolling_major_tag=$rolling_major_tag" >> "$GITHUB_OUTPUT"
|
fi
|
||||||
# echo "bump_kind=$bump_kind" >> "$GITHUB_OUTPUT"
|
|
||||||
# echo "should_publish=$should_publish" >> "$GITHUB_OUTPUT"
|
|
||||||
# echo "latest_release_tag=$latest_release_tag" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
# - name: Summarize release plan
|
git tag "$release_tag" "$GITHUB_SHA"
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# {
|
|
||||||
# echo "## Action release plan"
|
|
||||||
# echo ""
|
|
||||||
# echo "- Version: ${{ steps.derive.outputs.version }}"
|
|
||||||
# echo "- Release tag: ${{ steps.derive.outputs.release_tag }}"
|
|
||||||
# echo "- Rolling minor tag: ${{ steps.derive.outputs.rolling_minor_tag }}"
|
|
||||||
# echo "- Rolling major tag: ${{ steps.derive.outputs.rolling_major_tag }}"
|
|
||||||
# echo "- Bump kind: ${{ steps.derive.outputs.bump_kind }}"
|
|
||||||
# echo "- Latest published tag: ${{ steps.derive.outputs.latest_release_tag || 'none' }}"
|
|
||||||
# echo "- Will publish: ${{ steps.derive.outputs.should_publish }}"
|
|
||||||
# } >> "$GITHUB_STEP_SUMMARY"
|
|
||||||
|
|
||||||
# publish_tags:
|
- name: Update rolling tags
|
||||||
# name: Publish tags
|
shell: bash
|
||||||
# runs-on: linux
|
run: |
|
||||||
# needs: derive_release
|
set -euo pipefail
|
||||||
# if: ${{ needs.derive_release.outputs.should_publish == 'true' }}
|
git tag -f '${{ needs.derive_release.outputs.rolling_minor_tag }}' "$GITHUB_SHA"
|
||||||
# steps:
|
git tag -f '${{ needs.derive_release.outputs.rolling_major_tag }}' "$GITHUB_SHA"
|
||||||
# - name: Checkout repository
|
|
||||||
# uses: actions/checkout@v4
|
|
||||||
# with:
|
|
||||||
# fetch-depth: 0
|
|
||||||
|
|
||||||
# - name: Create immutable release tag
|
- name: Push release tags
|
||||||
# shell: bash
|
shell: bash
|
||||||
# run: |
|
run: |
|
||||||
# set -euo pipefail
|
set -euo pipefail
|
||||||
# release_tag='${{ needs.derive_release.outputs.release_tag }}'
|
git push origin '${{ needs.derive_release.outputs.release_tag }}'
|
||||||
|
git push origin '${{ needs.derive_release.outputs.rolling_minor_tag }}' --force
|
||||||
|
git push origin '${{ needs.derive_release.outputs.rolling_major_tag }}' --force
|
||||||
|
|
||||||
# if git rev-parse "$release_tag" >/dev/null 2>&1; then
|
- name: Summarize published tags
|
||||||
# echo "Release tag $release_tag already exists" >&2
|
shell: bash
|
||||||
# exit 1
|
run: |
|
||||||
# fi
|
{
|
||||||
|
echo "## Published action tags"
|
||||||
# git tag "$release_tag" "$GITHUB_SHA"
|
echo ""
|
||||||
|
echo "- Immutable: ${{ needs.derive_release.outputs.release_tag }}"
|
||||||
# - name: Update rolling tags
|
echo "- Rolling minor: ${{ needs.derive_release.outputs.rolling_minor_tag }}"
|
||||||
# shell: bash
|
echo "- Rolling major: ${{ needs.derive_release.outputs.rolling_major_tag }}"
|
||||||
# run: |
|
echo "- Bump kind: ${{ needs.derive_release.outputs.bump_kind }}"
|
||||||
# set -euo pipefail
|
} >> "$GITHUB_STEP_SUMMARY"
|
||||||
# git tag -f '${{ needs.derive_release.outputs.rolling_minor_tag }}' "$GITHUB_SHA"
|
|
||||||
# git tag -f '${{ needs.derive_release.outputs.rolling_major_tag }}' "$GITHUB_SHA"
|
|
||||||
|
|
||||||
# - name: Push release tags
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# set -euo pipefail
|
|
||||||
# git push origin '${{ needs.derive_release.outputs.release_tag }}'
|
|
||||||
# git push origin '${{ needs.derive_release.outputs.rolling_minor_tag }}' --force
|
|
||||||
# git push origin '${{ needs.derive_release.outputs.rolling_major_tag }}' --force
|
|
||||||
|
|
||||||
# - name: Summarize published tags
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# {
|
|
||||||
# echo "## Published action tags"
|
|
||||||
# echo ""
|
|
||||||
# echo "- Immutable: ${{ needs.derive_release.outputs.release_tag }}"
|
|
||||||
# echo "- Rolling minor: ${{ needs.derive_release.outputs.rolling_minor_tag }}"
|
|
||||||
# echo "- Rolling major: ${{ needs.derive_release.outputs.rolling_major_tag }}"
|
|
||||||
# echo "- Bump kind: ${{ needs.derive_release.outputs.bump_kind }}"
|
|
||||||
# } >> "$GITHUB_STEP_SUMMARY"
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user