Skip to content

Commit

Permalink
Update to node18 + update actions (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed Jan 9, 2023
1 parent 5e7a9fc commit 685f560
Show file tree
Hide file tree
Showing 22 changed files with 2,506 additions and 4,038 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/auto-git-release-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Summary:
# Automatically tag and release when changes land on the "main" branch.
#
# See https://github.com/PaulHatch/semantic-version https://github.com/PaulHatch/semantic-version/tree/v5.0.2
# See https://github.com/softprops/action-gh-release https://github.com/softprops/action-gh-release/tree/v1

name: 'Auto release'
on:
push:
branches:
- main

jobs:
tag-and-release:
runs-on: ubuntu-22.04
steps:
- name: Fetching all commits for the current branch
uses: actions/checkout@v3
with:
fetch-depth: 0 # Force fetch all commits - See https://github.com/PaulHatch/semantic-version#important-note-regarding-the-checkout-action

# Outputs documentation: https://github.com/PaulHatch/semantic-version/blob/master/src/main.ts#L22-L33
- name: Resolving next Release Candidate version using semantic-version
uses: paulhatch/semantic-version@v5.0.2
id: next_semantic_version
with: # See https://github.com/PaulHatch/semantic-version#usage
tag_prefix: "v" # The prefix to use to identify tags
major_pattern: "(MAJOR)" # A string which, if present in a git commit, indicates that a change represents a major (breaking) change
minor_pattern: "(MINOR)" # Same as above except indicating a minor change
version_format: "${major}.${minor}.${patch}-rc.${increment}" # A string to determine the format of the version output
bump_each_commit: true # If this input is set to true, every commit will be treated as a new version, bumping the patch, minor, or major version based on the commit message.

- name: Printing semantic-version outputs (for debugging)
run: |
echo "Most useful outputs:"
echo "Next version: ${{steps.next_semantic_version.outputs.version}}"
echo "Next version tag: ${{steps.next_semantic_version.outputs.version_tag}}"
echo -e "\n All outputs:"
echo "version: ${{steps.next_semantic_version.outputs.version}}"
echo "major: ${{steps.next_semantic_version.outputs.major}}"
echo "minor: ${{steps.next_semantic_version.outputs.minor}}"
echo "patch: ${{steps.next_semantic_version.outputs.patch}}"
echo "increment: ${{steps.next_semantic_version.outputs.increment}}"
echo "version_type: ${{steps.next_semantic_version.outputs.version_type}}"
echo "changed: ${{steps.next_semantic_version.outputs.changed}}"
echo "authors: ${{steps.next_semantic_version.outputs.authors}}"
echo "version_tag: ${{steps.next_semantic_version.outputs.version_tag}}"
echo "previous_commit: ${{steps.next_semantic_version.outputs.previous_commit}}"
echo "current_commit: ${{steps.next_semantic_version.outputs.current_commit}}"
- name: Creating Git release tag for the "${{steps.next_semantic_version.outputs.version_tag}}" version
uses: softprops/action-gh-release@v1
with: # See https://github.com/softprops/action-gh-release#-customizing
token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: ${{steps.next_semantic_version.outputs.version_tag}}
name: "Automatic release ${{steps.next_semantic_version.outputs.version_tag}}"
prerelease: false
generate_release_notes: true
files: |
CHANGELOG.md
- name: Updating Git release tag for "latest" version
uses: softprops/action-gh-release@v1
with: # See https://github.com/softprops/action-gh-release#-customizing
token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: latest
name: "Latest release (auto-update) - UNSAFE for production usage"
prerelease: false
generate_release_notes: true
files: |
CHANGELOG.md
- name: Updating Git release tag for the major "${{steps.next_semantic_version.outputs.major}}" version
uses: softprops/action-gh-release@v1
with: # See https://github.com/softprops/action-gh-release#-customizing
token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: ${{steps.next_semantic_version.outputs.major}}
name: "${{steps.next_semantic_version.outputs.major}} latest release (auto-update)"
prerelease: false
generate_release_notes: true
files: |
CHANGELOG.md
81 changes: 81 additions & 0 deletions .github/workflows/auto-git-release-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Summary:
# Automatically tag and release when changes land on the "main" branch.
#
# See https://github.com/PaulHatch/semantic-version https://github.com/PaulHatch/semantic-version/tree/v5.0.2
# See https://github.com/softprops/action-gh-release https://github.com/softprops/action-gh-release/tree/v1

name: 'Auto release (release candidate)'
on:
push:
branches-ignore:
- main

jobs:
tag-and-release:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Force fetch all commits - See https://github.com/PaulHatch/semantic-version#important-note-regarding-the-checkout-action

# Outputs documentation: https://github.com/PaulHatch/semantic-version/blob/master/src/main.ts#L22-L33
- name: Resolving next Release Candidate version using semantic-version
uses: paulhatch/semantic-version@v5.0.2
id: next_semantic_version
with: # See https://github.com/PaulHatch/semantic-version#usage
tag_prefix: "v" # The prefix to use to identify tags
major_pattern: "(MAJOR)" # A string which, if present in a git commit, indicates that a change represents a major (breaking) change
minor_pattern: "(MINOR)" # Same as above except indicating a minor change
version_format: "${major}.${minor}.${patch}-rc.${increment}" # A string to determine the format of the version output
bump_each_commit: false # If this input is set to true, every commit will be treated as a new version, bumping the patch, minor, or major version based on the commit message.

- name: Printing semantic-version outputs (for debugging)
run: |
echo "Most useful outputs:"
echo "Next version: ${{steps.next_semantic_version.outputs.version}}"
echo "Next version tag: ${{steps.next_semantic_version.outputs.version_tag}}"
echo -e "\n All outputs:"
echo "version: ${{steps.next_semantic_version.outputs.version}}"
echo "major: ${{steps.next_semantic_version.outputs.major}}"
echo "minor: ${{steps.next_semantic_version.outputs.minor}}"
echo "patch: ${{steps.next_semantic_version.outputs.patch}}"
echo "increment: ${{steps.next_semantic_version.outputs.increment}}"
echo "version_type: ${{steps.next_semantic_version.outputs.version_type}}"
echo "changed: ${{steps.next_semantic_version.outputs.changed}}"
echo "authors: ${{steps.next_semantic_version.outputs.authors}}"
echo "version_tag: ${{steps.next_semantic_version.outputs.version_tag}}"
echo "previous_commit: ${{steps.next_semantic_version.outputs.previous_commit}}"
echo "current_commit: ${{steps.next_semantic_version.outputs.current_commit}}"
- name: Creating Git release tag for the ${{steps.next_semantic_version.outputs.version}} version
uses: softprops/action-gh-release@v1
with: # See https://github.com/softprops/action-gh-release#-customizing
token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: ${{steps.next_semantic_version.outputs.version}}
name: "Automatic release ${{steps.next_semantic_version.outputs.version}}"
prerelease: true
generate_release_notes: true
files: |
CHANGELOG.md
- name: Updating Git release tag for "latest-rc" version
uses: softprops/action-gh-release@v1
with: # See https://github.com/softprops/action-gh-release#-customizing
token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: latest-rc
name: "Latest release (auto-update) - UNSAFE for production usage"
prerelease: true
generate_release_notes: true
files: |
CHANGELOG.md
- name: Updating Git release tag for the major "${{steps.next_semantic_version.outputs.major}}-rc" version
uses: softprops/action-gh-release@v1
with: # See https://github.com/softprops/action-gh-release#-customizing
token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: "${{steps.next_semantic_version.outputs.major}}-rc"
name: "${{steps.next_semantic_version.outputs.major}}-rc latest release (auto-update)"
prerelease: true
generate_release_notes: true
files: |
CHANGELOG.md
50 changes: 0 additions & 50 deletions .github/workflows/auto-git-release.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/auto-tag-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
# This way, consumers can use @v1 and the @v1 is a tag that is automatically updated when you release a new v1 minor/patch version.
# Note that if you release a "pre-release", it won't automatically update the "latest" tag, nor the MAJOR tag.
#
# See https://github.com/Actions-R-Us/actions-tagger https://github.com/Actions-R-Us/actions-tagger/releases/tag/v2.0.1
# See https://github.com/Actions-R-Us/actions-tagger https://github.com/Actions-R-Us/actions-tagger/releases/tag/v2.0.3

name: 'Auto-tag upon release'
on:
release:
types: [published, edited]
types: [ published, edited ]

jobs:
actions-tagger:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: Actions-R-Us/actions-tagger@v2.0.1
- uses: Actions-R-Us/actions-tagger@v2.0.3
env:
GITHUB_TOKEN: "${{ github.token }}"
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
# Summary:
# Test actual example used in README.md
# Makes sure the GitHub Action builds when being built by GitHub Actions.
# Tests the example used in README.md, to make sure the example we show is always working.
#
# See https://github.com/actions/checkout https://github.com/actions/checkout/releases/tag/v2
# See https://github.com/actions/checkout https://github.com/actions/checkout/releases/tag/v3

name: 'GitHub Action code snippet'
on:
push:
branches:
- '*'

jobs:
# On some job, do some stuff an persist variables meant to be re-used in other jobs
# We want to wait for the auto-git-release-x to be done, so that we always test the MAJOR version that was just updated
await-release:
name: Sleep for 45 seconds
runs-on: ubuntu-22.04
steps:
- run: sleep 45s
shell: bash

# On some job, do some stuff and persist variables meant to be re-used in other jobs
compute-data:
name: Compute data
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: await-release
steps:
# Do your own internal business logic...
- name: Compute ressource
- name: Compute resources
run: |
MAGIC_NUMBER=42
echo "Found universal answer: $MAGIC_NUMBER"
echo "Exporting it as ENV variable..."
echo "MAGIC_NUMBER=$MAGIC_NUMBER" >> $GITHUB_ENV
# XXX We recommend to export all your variables at once, at the end of your job
- name: Export variable for next jobs
uses: UnlyEd/github-action-store-variable@v2.1.1 # See https://github.com/UnlyEd/github-action-store-variable
- name: Export variable MAGIC_NUMBER for next jobs
uses: UnlyEd/github-action-store-variable@v3 # See https://github.com/UnlyEd/github-action-store-variable
with:
# Persist (store) our MAGIC_NUMBER ENV variable into our store, for the next jobs
variables: |
Expand All @@ -34,11 +41,11 @@ jobs:
# In another job, read the previously stored variable and use it
retrieve-data:
name: Find & re-use data
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: compute-data
steps:
- name: Import variable MAGIC_NUMBER
uses: UnlyEd/github-action-store-variable@v2.1.1 # See https://github.com/UnlyEd/github-action-store-variable
uses: UnlyEd/github-action-store-variable@v3 # See https://github.com/UnlyEd/github-action-store-variable
with:
# List all variables you want to retrieve from the store
# XXX They'll be automatically added to your ENV
Expand All @@ -48,22 +55,22 @@ jobs:
run: echo "We have access to $MAGIC_NUMBER"

save-many-variables-by-using-custom-delimiter:
name: Save many variable by using a custom delimiter (comma)
runs-on: ubuntu-18.04
name: Save many variables by using a custom delimiter (comma)
runs-on: ubuntu-22.04
steps:
- name: Export variable for next jobs
uses: UnlyEd/github-action-store-variable@v2.1.1 # See https://github.com/UnlyEd/github-action-store-variable
uses: UnlyEd/github-action-store-variable@v3 # See https://github.com/UnlyEd/github-action-store-variable
with:
delimiter: ','
variables: FOO=BAR,STAGE=production

retrieve-data-saved-with-a-custom-delimiter:
name: Retrieve data saved with a custom delimiter
runs-on: ubuntu-18.04
name: Retrieve variables using a custom delimiter
runs-on: ubuntu-22.04
needs: save-many-variables-by-using-custom-delimiter
steps:
- name: Import variable MAGIC_NUMBER
uses: UnlyEd/github-action-store-variable@v2.1.1 # See https://github.com/UnlyEd/github-action-store-variable
uses: UnlyEd/github-action-store-variable@v3 # See https://github.com/UnlyEd/github-action-store-variable
with:
delimiter: ';'
variables: FOO;STAGE
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Summary:
# Test if the the GitHub Action builds correctly.
# Test if the GitHub Action builds correctly.
# Makes sure the GitHub Action builds when being built by GitHub Actions.
#
# See https://github.com/actions/checkout https://github.com/actions/checkout/releases/tag/v2
# See https://github.com/actions/checkout https://github.com/actions/checkout/releases/tag/v3

name: 'GitHub Action build test'
on:
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
run-build-test:
runs-on: ubuntu-18.04
strategy:
matrix:
version: [ 16, 18, 20 ]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: |
yarn
yarn build:once
Loading

0 comments on commit 685f560

Please sign in to comment.