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

Add a workflow to keep meta-package versions in sync #42

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Exclude for archive generation
/.git* export-ignore
89 changes: 89 additions & 0 deletions .github/workflows/versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Versions

on:
workflow_dispatch:
inputs:
dry-run:
required: true
type: boolean
default: true
# schedule:
# - cron: '*/10 * * * *'

jobs:
sync:
name: Sync
runs-on: ubuntu-latest
outputs:
tags-matrix: steps.tags-matrix.outputs.result
latest-release: steps.latest-release.outputs.result
steps:
- name: Get upstream package name
id: package
run: echo "::set-output name=package-name::$(jq -r '.require | map_values(select(. == "self.version")) | keys[0]' composer.json)"

- name: Generate diff of versions arrays
id: tags-matrix
uses: actions/github-script@v6
env:
PACKAGE: ${{ steps.package.outputs.package-name }}
with:
script: |
const { PACKAGE } = process.env
const currrentTags = github.rest.repos.listTags({
owner: context.repo.owner,
repo: context.repo.repo,
})
const upstreamTags = github.rest.repos.listTags({
owner: context.repo.owner,
repo: PACKAGE.substring(str.indexOf('/') + 1),
per_page: 15
})
return upstreamTags.filter((tag) => !currrentTags.includes(tag))

- name: Extract latest release
id: latest-release
env:
TAGS: ${{ steps.tags-matrix.outputs.result }}
run: echo "::set-output name=result::$(jq -r '.[0]' <<< "$TAGS")"

tags:
name: Tags
runs-on: ubuntu-latest
needs:
- sync
if: needs.sync.outputs.tags-matrix
strategy:
fail-fast: false
matrix:
tag: ${{ fromJSON(needs.sync.outputs.tags-matrix) }}
steps:
- name: Create a tag
uses: rickstaa/action-create-tag@v1
if: ${{ ! inputs.dry-run }}
with:
tag: ${{ matrix.tag }}
message: ${{ matrix.tag }}

release:
name: Release
runs-on: ubuntu-latest
needs:
- sync
- tags
if: needs.sync.outputs.latest-release
steps:
- name: Generate token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_PRIVATE_KEY }}

- name: Create a release
uses: softprops/action-gh-release@v1
if: ${{ ! inputs.dry-run }}
with:
token: ${{ steps.generate-token.outputs.token }}
body: Version ${{ needs.sync.outputs.latest-release }}
tag_name: ${{ needs.sync.outputs.latest-release }}